@monolythium/core-sdk 0.4.23 → 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/README.md +17 -9
- package/dist/crypto/index.cjs +51 -617
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +116 -31
- package/dist/crypto/index.d.ts +116 -31
- package/dist/crypto/index.js +44 -564
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +912 -951
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7411 -391
- package/dist/index.d.ts +7411 -391
- package/dist/index.js +876 -946
- package/dist/index.js.map +1 -1
- package/dist/ml-dsa-Drcmrw5h.d.cts +90 -0
- package/dist/ml-dsa-Drcmrw5h.d.ts +90 -0
- package/package.json +1 -1
- package/dist/submission-B4FmDnm_.d.cts +0 -7079
- package/dist/submission-B4FmDnm_.d.ts +0 -7079
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var blake3_js = require('@noble/hashes/blake3.js');
|
|
4
4
|
var sha3_js = require('@noble/hashes/sha3.js');
|
|
5
|
-
var mlKem_js = require('@noble/post-quantum/ml-kem.js');
|
|
6
|
-
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
7
|
-
require('@noble/hashes/utils.js');
|
|
8
5
|
var mlDsa_js = require('@noble/post-quantum/ml-dsa.js');
|
|
9
6
|
var bls12381_js = require('@noble/curves/bls12-381.js');
|
|
10
7
|
var bip39 = require('@scure/bip39');
|
|
@@ -382,10 +379,6 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
382
379
|
formClusterV2: "0x" + selectorHex("formCluster(bytes,bytes,bytes,bytes)"),
|
|
383
380
|
/** `setOperatorDisplay(bytes32,string,string)` — owner-callable public display metadata. */
|
|
384
381
|
setOperatorDisplay: "0x" + selectorHex("setOperatorDisplay(bytes32,string,string)"),
|
|
385
|
-
/** `publishOperatorSealKey(bytes32,bytes)` — owner-callable LythiumSeal EK publication. */
|
|
386
|
-
publishOperatorSealKey: "0x" + selectorHex("publishOperatorSealKey(bytes32,bytes)"),
|
|
387
|
-
/** `getOperatorSealKey(bytes32)` view — returns the operator's published LythiumSeal EK. */
|
|
388
|
-
getOperatorSealKey: "0x" + selectorHex("getOperatorSealKey(bytes32)"),
|
|
389
382
|
/**
|
|
390
383
|
* `updateCharter(uint32,bytes,bytes,bytes)` — Component H live charter
|
|
391
384
|
* amendment (Law §6.8); re-signs a new 30-byte charter for a LIVE cluster
|
|
@@ -411,7 +404,35 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
411
404
|
/** `getProbeAuthority()` view — Component C configured probe-authority address. */
|
|
412
405
|
getProbeAuthority: "0x" + selectorHex("getProbeAuthority()"),
|
|
413
406
|
/** `attestServiceProbe(bytes32,uint32,uint8,uint64)` — Component C attested score-eligibility path. */
|
|
414
|
-
attestServiceProbe: "0x" + selectorHex("attestServiceProbe(bytes32,uint32,uint8,uint64)")
|
|
407
|
+
attestServiceProbe: "0x" + selectorHex("attestServiceProbe(bytes32,uint32,uint8,uint64)"),
|
|
408
|
+
/**
|
|
409
|
+
* `advertiseSeat(uint32,uint8,uint32,uint128,uint32,bytes32)` returns
|
|
410
|
+
* `uint32 seatId` (L6 open-seat marketplace). Publishes a vacancy
|
|
411
|
+
* listing; caller must own an active member op-hash of the cluster.
|
|
412
|
+
*/
|
|
413
|
+
advertiseSeat: "0x" + selectorHex("advertiseSeat(uint32,uint8,uint32,uint128,uint32,bytes32)"),
|
|
414
|
+
/**
|
|
415
|
+
* `applyForSeat(uint32,uint32,bytes)` returns `bytes32 appKey` (L6).
|
|
416
|
+
* Payable — the native `value` carries the refundable application
|
|
417
|
+
* escrow ({@link NODE_REGISTRY_SEAT_APPLICATION_ESCROW_LYTHOSHI}).
|
|
418
|
+
*/
|
|
419
|
+
applyForSeat: "0x" + selectorHex("applyForSeat(uint32,uint32,bytes)"),
|
|
420
|
+
/**
|
|
421
|
+
* `voteSeatAdmit(uint32,bytes32,bytes)` returns `uint16 voteCount`
|
|
422
|
+
* (L6). Active-member admission vote; the 7-of-10 threshold-reaching
|
|
423
|
+
* vote fills the seat and admits the operator.
|
|
424
|
+
*/
|
|
425
|
+
voteSeatAdmit: "0x" + selectorHex("voteSeatAdmit(uint32,bytes32,bytes)"),
|
|
426
|
+
/**
|
|
427
|
+
* `withdrawSeatApplication(uint32,bytes32)` returns `bool` (L6) —
|
|
428
|
+
* applicant withdrawal that refunds the escrow.
|
|
429
|
+
*/
|
|
430
|
+
withdrawSeatApplication: "0x" + selectorHex("withdrawSeatApplication(uint32,bytes32)"),
|
|
431
|
+
/**
|
|
432
|
+
* `closeSeat(uint32,uint32)` returns `bool` (L6) — advertiser rescind
|
|
433
|
+
* of an `Open` listing.
|
|
434
|
+
*/
|
|
435
|
+
closeSeat: "0x" + selectorHex("closeSeat(uint32,uint32)")
|
|
415
436
|
};
|
|
416
437
|
var NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES = 48;
|
|
417
438
|
var NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
|
|
@@ -419,7 +440,6 @@ var NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
|
|
|
419
440
|
var NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES = 1952;
|
|
420
441
|
var NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES = 3309;
|
|
421
442
|
var NODE_REGISTRY_CONSENSUS_POP_BYTES = 3309;
|
|
422
|
-
var NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES = 1184;
|
|
423
443
|
var NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES = 96;
|
|
424
444
|
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES;
|
|
425
445
|
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
@@ -686,43 +706,6 @@ function encodeSetOperatorDisplayCalldata(args) {
|
|
|
686
706
|
)
|
|
687
707
|
);
|
|
688
708
|
}
|
|
689
|
-
function encodePublishOperatorSealKeyCalldata(args) {
|
|
690
|
-
const peerId = expectLength2(toBytes(args.peerId), 32, "peerId");
|
|
691
|
-
const sealEk = expectNonZeroBytes(
|
|
692
|
-
expectLength2(toBytes(args.sealEk), NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES, "sealEk"),
|
|
693
|
-
"sealEk"
|
|
694
|
-
);
|
|
695
|
-
const sealEkPadded = padToWord(sealEk);
|
|
696
|
-
return bytesToHex(
|
|
697
|
-
concatBytes(
|
|
698
|
-
hexToBytes(NODE_REGISTRY_SELECTORS.publishOperatorSealKey),
|
|
699
|
-
peerId,
|
|
700
|
-
uint64Word(2n * 32n, "sealEkOffset"),
|
|
701
|
-
uint64Word(BigInt(sealEk.length), "sealEkLength"),
|
|
702
|
-
sealEkPadded
|
|
703
|
-
)
|
|
704
|
-
);
|
|
705
|
-
}
|
|
706
|
-
function encodeGetOperatorSealKeyCalldata(args) {
|
|
707
|
-
return bytesToHex(
|
|
708
|
-
concatBytes(
|
|
709
|
-
hexToBytes(NODE_REGISTRY_SELECTORS.getOperatorSealKey),
|
|
710
|
-
expectLength2(toBytes(args.operatorId), 32, "operatorId")
|
|
711
|
-
)
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
function decodeOperatorSealKey(returnData) {
|
|
715
|
-
const bytes = toBytes(returnData);
|
|
716
|
-
if (bytes.length === NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES) {
|
|
717
|
-
return bytesToHex(expectNonZeroBytes(bytes, "operatorSealKey"));
|
|
718
|
-
}
|
|
719
|
-
const sealEk = decodeDynamicBytesResult(
|
|
720
|
-
bytes,
|
|
721
|
-
NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES,
|
|
722
|
-
"operatorSealKey"
|
|
723
|
-
);
|
|
724
|
-
return bytesToHex(expectNonZeroBytes(sealEk, "operatorSealKey"));
|
|
725
|
-
}
|
|
726
709
|
function encodeCancelClusterJoinCalldata(args) {
|
|
727
710
|
return bytesToHex(
|
|
728
711
|
concatBytes(
|
|
@@ -1396,6 +1379,253 @@ function deriveClusterAnchorAddress(roster, threshold) {
|
|
|
1396
1379
|
}
|
|
1397
1380
|
return bytesToHex(blake3_js.blake3(concatBytes(...parts)).slice(0, 20));
|
|
1398
1381
|
}
|
|
1382
|
+
var NODE_REGISTRY_TAG_CLUSTER_SEAT = 50;
|
|
1383
|
+
var NODE_REGISTRY_SEAT_APPLICATION_ESCROW_LYTHOSHI = 100n * 1000000000000000000n;
|
|
1384
|
+
var NODE_REGISTRY_MIN_SELF_BOND_LYTHOSHI = 5000n * 1000000000000000000n;
|
|
1385
|
+
var NODE_REGISTRY_SEAT_KIND_ACTIVE = 0;
|
|
1386
|
+
var NODE_REGISTRY_SEAT_KIND_STANDBY = 1;
|
|
1387
|
+
function seatKindFromByte(b) {
|
|
1388
|
+
return b === NODE_REGISTRY_SEAT_KIND_STANDBY ? "standby" : "active";
|
|
1389
|
+
}
|
|
1390
|
+
function seatKindToByte(kind) {
|
|
1391
|
+
return kind === "standby" ? NODE_REGISTRY_SEAT_KIND_STANDBY : NODE_REGISTRY_SEAT_KIND_ACTIVE;
|
|
1392
|
+
}
|
|
1393
|
+
var SEAT_STATUS_CODES = {
|
|
1394
|
+
none: 0,
|
|
1395
|
+
open: 1,
|
|
1396
|
+
filled: 2,
|
|
1397
|
+
closed: 3
|
|
1398
|
+
};
|
|
1399
|
+
function seatStatusFromByte(b) {
|
|
1400
|
+
switch (b) {
|
|
1401
|
+
case 1:
|
|
1402
|
+
return "open";
|
|
1403
|
+
case 2:
|
|
1404
|
+
return "filled";
|
|
1405
|
+
case 3:
|
|
1406
|
+
return "closed";
|
|
1407
|
+
default:
|
|
1408
|
+
return "none";
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
var SEAT_ADVERTISED_EVENT_SIG = "SeatAdvertised(uint32,uint32,bytes32,uint8,uint32,uint128,uint32,bytes32)";
|
|
1412
|
+
var SEAT_APPLIED_EVENT_SIG = "SeatApplied(uint32,uint32,bytes32,address,uint128)";
|
|
1413
|
+
var SEAT_FILLED_EVENT_SIG = "SeatFilled(uint32,uint32,bytes32,uint16,uint16)";
|
|
1414
|
+
var SEAT_CLOSED_EVENT_SIG = "SeatClosed(uint32,uint32,uint8)";
|
|
1415
|
+
function encodeAdvertiseSeatCalldata(args) {
|
|
1416
|
+
const kindByte = typeof args.kind === "number" ? args.kind : seatKindToByte(args.kind);
|
|
1417
|
+
if (!Number.isInteger(kindByte) || kindByte < 0 || kindByte > 255) {
|
|
1418
|
+
throw new NodeRegistryError("kind must be a u8 seat kind (0 = active, 1 = standby)");
|
|
1419
|
+
}
|
|
1420
|
+
return bytesToHex(
|
|
1421
|
+
concatBytes(
|
|
1422
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.advertiseSeat),
|
|
1423
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
1424
|
+
uint8Word(kindByte),
|
|
1425
|
+
uint32Word(toUint32(args.seatCount, "seatCount")),
|
|
1426
|
+
uint128Word(args.minBondLythoshi, "minBondLythoshi"),
|
|
1427
|
+
uint32Word(toUint32(args.capabilityMask, "capabilityMask")),
|
|
1428
|
+
expectLength2(toBytes(args.termsHash), 32, "termsHash")
|
|
1429
|
+
)
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1432
|
+
function encodeApplyForSeatCalldata(args) {
|
|
1433
|
+
const operatorPubkey = expectLength2(
|
|
1434
|
+
toBytes(args.operatorPubkey),
|
|
1435
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
1436
|
+
"operatorPubkey"
|
|
1437
|
+
);
|
|
1438
|
+
const operatorPubkeyPadded = padToWord(operatorPubkey);
|
|
1439
|
+
return bytesToHex(
|
|
1440
|
+
concatBytes(
|
|
1441
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.applyForSeat),
|
|
1442
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
1443
|
+
uint32Word(toUint32(args.seatId, "seatId")),
|
|
1444
|
+
uint64Word(3n * 32n, "operatorPubkeyOffset"),
|
|
1445
|
+
uint64Word(BigInt(operatorPubkey.length), "operatorPubkeyLength"),
|
|
1446
|
+
operatorPubkeyPadded
|
|
1447
|
+
)
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
function encodeVoteSeatAdmitCalldata(args) {
|
|
1451
|
+
const appKey = expectLength2(toBytes(args.appKey), 32, "appKey");
|
|
1452
|
+
const voterPubkey = expectLength2(
|
|
1453
|
+
toBytes(args.voterPubkey),
|
|
1454
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
1455
|
+
"voterPubkey"
|
|
1456
|
+
);
|
|
1457
|
+
const voterPubkeyPadded = padToWord(voterPubkey);
|
|
1458
|
+
return bytesToHex(
|
|
1459
|
+
concatBytes(
|
|
1460
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.voteSeatAdmit),
|
|
1461
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
1462
|
+
appKey,
|
|
1463
|
+
uint64Word(3n * 32n, "voterPubkeyOffset"),
|
|
1464
|
+
uint64Word(BigInt(voterPubkey.length), "voterPubkeyLength"),
|
|
1465
|
+
voterPubkeyPadded
|
|
1466
|
+
)
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
function encodeWithdrawSeatApplicationCalldata(args) {
|
|
1470
|
+
return bytesToHex(
|
|
1471
|
+
concatBytes(
|
|
1472
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.withdrawSeatApplication),
|
|
1473
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
1474
|
+
expectLength2(toBytes(args.appKey), 32, "appKey")
|
|
1475
|
+
)
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
function encodeCloseSeatCalldata(args) {
|
|
1479
|
+
return bytesToHex(
|
|
1480
|
+
concatBytes(
|
|
1481
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.closeSeat),
|
|
1482
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
1483
|
+
uint32Word(toUint32(args.seatId, "seatId"))
|
|
1484
|
+
)
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
function deriveSeatApplicationKey(operatorPubkey) {
|
|
1488
|
+
return bytesToHex(
|
|
1489
|
+
blake3_js.blake3(expectLength2(toBytes(operatorPubkey), NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES, "operatorPubkey"))
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
function decodeSeatAdvertisedEvent(topics, data) {
|
|
1493
|
+
const { clusterId, seatId } = decodeSeatClusterSeatTopics(topics, SEAT_ADVERTISED_EVENT_SIG, 3);
|
|
1494
|
+
const body = toBytes(data);
|
|
1495
|
+
if (body.length < 6 * 32) {
|
|
1496
|
+
throw new NodeRegistryError("SeatAdvertised data shorter than the 6-word body");
|
|
1497
|
+
}
|
|
1498
|
+
const word = (i) => body.slice(i * 32, (i + 1) * 32);
|
|
1499
|
+
return {
|
|
1500
|
+
clusterId,
|
|
1501
|
+
seatId,
|
|
1502
|
+
advertiser: bytesToHex(word(0)),
|
|
1503
|
+
kind: numberFromWord(word(1), "kind", 255),
|
|
1504
|
+
seatCount: u32FromWord(word(2)),
|
|
1505
|
+
minBondLythoshi: uintFromWord(word(3)),
|
|
1506
|
+
capabilityMask: u32FromWord(word(4)),
|
|
1507
|
+
termsHash: bytesToHex(word(5))
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function decodeSeatAppliedEvent(topics, data) {
|
|
1511
|
+
const { clusterId, seatId, operatorId } = decodeSeatClusterSeatOperatorTopics(
|
|
1512
|
+
topics,
|
|
1513
|
+
SEAT_APPLIED_EVENT_SIG
|
|
1514
|
+
);
|
|
1515
|
+
const body = toBytes(data);
|
|
1516
|
+
if (body.length < 2 * 32) {
|
|
1517
|
+
throw new NodeRegistryError("SeatApplied data shorter than the 2-word body");
|
|
1518
|
+
}
|
|
1519
|
+
return {
|
|
1520
|
+
clusterId,
|
|
1521
|
+
seatId,
|
|
1522
|
+
operatorId,
|
|
1523
|
+
owner: bytesToHex(body.slice(12, 32)),
|
|
1524
|
+
escrowLythoshi: uintFromWord(body.slice(32, 64))
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
function decodeSeatFilledEvent(topics, data) {
|
|
1528
|
+
const { clusterId, seatId, operatorId } = decodeSeatClusterSeatOperatorTopics(
|
|
1529
|
+
topics,
|
|
1530
|
+
SEAT_FILLED_EVENT_SIG
|
|
1531
|
+
);
|
|
1532
|
+
const body = toBytes(data);
|
|
1533
|
+
if (body.length < 2 * 32) {
|
|
1534
|
+
throw new NodeRegistryError("SeatFilled data shorter than the 2-word body");
|
|
1535
|
+
}
|
|
1536
|
+
return {
|
|
1537
|
+
clusterId,
|
|
1538
|
+
seatId,
|
|
1539
|
+
operatorId,
|
|
1540
|
+
filledCount: numberFromWord(body.slice(0, 32), "filledCount", 65535),
|
|
1541
|
+
seatCount: numberFromWord(body.slice(32, 64), "seatCount", 65535)
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
function decodeSeatClosedEvent(topics, data) {
|
|
1545
|
+
const { clusterId, seatId } = decodeSeatClusterSeatTopics(topics, SEAT_CLOSED_EVENT_SIG, 3);
|
|
1546
|
+
const body = toBytes(data);
|
|
1547
|
+
if (body.length < 32) {
|
|
1548
|
+
throw new NodeRegistryError("SeatClosed data shorter than the 1-word body");
|
|
1549
|
+
}
|
|
1550
|
+
return {
|
|
1551
|
+
clusterId,
|
|
1552
|
+
seatId,
|
|
1553
|
+
status: numberFromWord(body.slice(0, 32), "status", 255)
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
function openSeatFromAdvertised(event) {
|
|
1557
|
+
return {
|
|
1558
|
+
clusterId: event.clusterId,
|
|
1559
|
+
seatId: event.seatId,
|
|
1560
|
+
advertiser: event.advertiser,
|
|
1561
|
+
kind: seatKindFromByte(event.kind),
|
|
1562
|
+
seatCount: event.seatCount,
|
|
1563
|
+
filledCount: 0,
|
|
1564
|
+
minBondLythoshi: event.minBondLythoshi,
|
|
1565
|
+
capabilityMask: event.capabilityMask,
|
|
1566
|
+
termsHash: event.termsHash,
|
|
1567
|
+
status: "open"
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function decodeSeatClusterSeatTopics(topics, sig, expectedCount) {
|
|
1571
|
+
if (topics.length !== expectedCount) {
|
|
1572
|
+
throw new NodeRegistryError(`${sig} expects ${expectedCount} topics, got ${topics.length}`);
|
|
1573
|
+
}
|
|
1574
|
+
assertEventTopic0(topics[0], sig);
|
|
1575
|
+
return {
|
|
1576
|
+
clusterId: u32FromWord(expectLength2(toBytes(topics[1]), 32, "clusterId topic")),
|
|
1577
|
+
seatId: u32FromWord(expectLength2(toBytes(topics[2]), 32, "seatId topic"))
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
function decodeSeatClusterSeatOperatorTopics(topics, sig) {
|
|
1581
|
+
if (topics.length !== 4) {
|
|
1582
|
+
throw new NodeRegistryError(`${sig} expects 4 topics, got ${topics.length}`);
|
|
1583
|
+
}
|
|
1584
|
+
assertEventTopic0(topics[0], sig);
|
|
1585
|
+
return {
|
|
1586
|
+
clusterId: u32FromWord(expectLength2(toBytes(topics[1]), 32, "clusterId topic")),
|
|
1587
|
+
seatId: u32FromWord(expectLength2(toBytes(topics[2]), 32, "seatId topic")),
|
|
1588
|
+
operatorId: bytesToHex(expectLength2(toBytes(topics[3]), 32, "operatorId topic"))
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
function assertEventTopic0(topic0, sig) {
|
|
1592
|
+
const got = bytesToHex(expectLength2(toBytes(topic0), 32, "topic0"));
|
|
1593
|
+
const want = bytesToHex(sha3_js.keccak_256(new TextEncoder().encode(sig)));
|
|
1594
|
+
if (got !== want) {
|
|
1595
|
+
throw new NodeRegistryError(`unexpected topic0 for ${sig}`);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
function uint128Word(value, name) {
|
|
1599
|
+
const n = toUint128(value, name);
|
|
1600
|
+
const out = new Uint8Array(32);
|
|
1601
|
+
let rest = n;
|
|
1602
|
+
for (let i = 31; i >= 16; i--) {
|
|
1603
|
+
out[i] = Number(rest & 0xffn);
|
|
1604
|
+
rest >>= 8n;
|
|
1605
|
+
}
|
|
1606
|
+
return out;
|
|
1607
|
+
}
|
|
1608
|
+
function toUint128(value, name) {
|
|
1609
|
+
let parsed;
|
|
1610
|
+
if (typeof value === "bigint") {
|
|
1611
|
+
parsed = value;
|
|
1612
|
+
} else if (typeof value === "number") {
|
|
1613
|
+
if (!Number.isSafeInteger(value)) {
|
|
1614
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
1615
|
+
}
|
|
1616
|
+
parsed = BigInt(value);
|
|
1617
|
+
} else {
|
|
1618
|
+
const trimmed = value.trim();
|
|
1619
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
1620
|
+
throw new NodeRegistryError(`${name} must be a decimal uint128`);
|
|
1621
|
+
}
|
|
1622
|
+
parsed = BigInt(trimmed);
|
|
1623
|
+
}
|
|
1624
|
+
if (parsed < 0n || parsed >= 1n << 128n) {
|
|
1625
|
+
throw new NodeRegistryError(`${name} must fit uint128`);
|
|
1626
|
+
}
|
|
1627
|
+
return parsed;
|
|
1628
|
+
}
|
|
1399
1629
|
function selectorHex(sig) {
|
|
1400
1630
|
return [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1401
1631
|
}
|
|
@@ -1651,30 +1881,6 @@ function expectLength2(value, len, name) {
|
|
|
1651
1881
|
}
|
|
1652
1882
|
return value;
|
|
1653
1883
|
}
|
|
1654
|
-
function expectNonZeroBytes(value, name) {
|
|
1655
|
-
if (value.every((byte) => byte === 0)) {
|
|
1656
|
-
throw new NodeRegistryError(`${name} must not be all-zero`);
|
|
1657
|
-
}
|
|
1658
|
-
return value;
|
|
1659
|
-
}
|
|
1660
|
-
function decodeDynamicBytesResult(bytes, expectedLength, label) {
|
|
1661
|
-
if (bytes.length < 64) {
|
|
1662
|
-
throw new NodeRegistryError(`${label} return must be ABI-encoded dynamic bytes`);
|
|
1663
|
-
}
|
|
1664
|
-
const offset = uintFromWord(bytes.slice(0, 32));
|
|
1665
|
-
if (offset !== 32n) {
|
|
1666
|
-
throw new NodeRegistryError(`${label} return offset must be 0x20`);
|
|
1667
|
-
}
|
|
1668
|
-
const len = uintFromWord(bytes.slice(32, 64));
|
|
1669
|
-
if (len !== BigInt(expectedLength)) {
|
|
1670
|
-
throw new NodeRegistryError(`${label} must be ${expectedLength} bytes, got ${len}`);
|
|
1671
|
-
}
|
|
1672
|
-
const paddedLen = Math.ceil(expectedLength / 32) * 32;
|
|
1673
|
-
if (bytes.length < 64 + paddedLen) {
|
|
1674
|
-
throw new NodeRegistryError(`${label} body is truncated`);
|
|
1675
|
-
}
|
|
1676
|
-
return bytes.slice(64, 64 + expectedLength);
|
|
1677
|
-
}
|
|
1678
1884
|
|
|
1679
1885
|
// src/native-events.ts
|
|
1680
1886
|
var NATIVE_MARKET_EVENT_FAMILY = "market";
|
|
@@ -1816,6 +2022,40 @@ function parseBigint(value, label) {
|
|
|
1816
2022
|
return BigInt(value);
|
|
1817
2023
|
}
|
|
1818
2024
|
|
|
2025
|
+
// src/crypto/submission.ts
|
|
2026
|
+
function buildPlaintextSubmission(args) {
|
|
2027
|
+
const signed = args.backend.signEvmTx(args.tx);
|
|
2028
|
+
return {
|
|
2029
|
+
signedTxWireHex: `0x${signed.wireHex}`,
|
|
2030
|
+
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
2031
|
+
innerSighashHex: bytesToHex2(signed.sighash),
|
|
2032
|
+
innerWireBytes: signed.wireBytes.length
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
async function submitPlaintextTransaction(client, signedTxWireHex, expectedTxHashHex) {
|
|
2036
|
+
const returned = await client.call("mesh_submitTx", [signedTxWireHex]);
|
|
2037
|
+
const returnedBytes = hexToBytes2(returned, "mesh_submitTx tx hash");
|
|
2038
|
+
if (returnedBytes.length !== 32) {
|
|
2039
|
+
throw new Error(
|
|
2040
|
+
`mesh_submitTx tx hash must be 32 bytes, got ${returnedBytes.length}`
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
const expectedBytes = hexToBytes2(expectedTxHashHex, "expected tx hash");
|
|
2044
|
+
if (!bytesEqual(returnedBytes, expectedBytes)) {
|
|
2045
|
+
throw new Error(
|
|
2046
|
+
`mesh_submitTx returned tx hash ${bytesToHex2(returnedBytes)} but the locally computed canonical hash is ${bytesToHex2(expectedBytes)}`
|
|
2047
|
+
);
|
|
2048
|
+
}
|
|
2049
|
+
return bytesToHex2(returnedBytes);
|
|
2050
|
+
}
|
|
2051
|
+
function bytesEqual(a, b) {
|
|
2052
|
+
if (a.length !== b.length) return false;
|
|
2053
|
+
for (let i = 0; i < a.length; i++) {
|
|
2054
|
+
if (a[i] !== b[i]) return false;
|
|
2055
|
+
}
|
|
2056
|
+
return true;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
1819
2059
|
// src/crypto/bincode.ts
|
|
1820
2060
|
var BincodeWriter = class {
|
|
1821
2061
|
#chunks = [];
|
|
@@ -1875,673 +2115,6 @@ var BincodeWriter = class {
|
|
|
1875
2115
|
}
|
|
1876
2116
|
};
|
|
1877
2117
|
|
|
1878
|
-
// src/crypto/tx.ts
|
|
1879
|
-
function encodeTransactionForHash(fields, tag) {
|
|
1880
|
-
const n = normalizeTxFields(fields);
|
|
1881
|
-
return concatBytes2(
|
|
1882
|
-
Uint8Array.of(tag),
|
|
1883
|
-
bigintToBeBytes(n.chainId, 8, "chainId"),
|
|
1884
|
-
bigintToBeBytes(n.nonce, 8, "nonce"),
|
|
1885
|
-
bigintToBeBytes(n.maxPriorityFeePerGas, 32, "maxPriorityFeePerGas"),
|
|
1886
|
-
bigintToBeBytes(n.maxFeePerGas, 32, "maxFeePerGas"),
|
|
1887
|
-
bigintToBeBytes(n.gasLimit, 8, "gasLimit"),
|
|
1888
|
-
n.to === null ? Uint8Array.of(0) : concatBytes2(Uint8Array.of(1), n.to),
|
|
1889
|
-
bigintToBeBytes(n.value, 32, "value"),
|
|
1890
|
-
bigintToBeBytes(BigInt(n.input.length), 4, "input.length"),
|
|
1891
|
-
n.input,
|
|
1892
|
-
new Uint8Array(4),
|
|
1893
|
-
// access_list length
|
|
1894
|
-
encodeExtensionsForHash(n.extensions)
|
|
1895
|
-
);
|
|
1896
|
-
}
|
|
1897
|
-
function bincodeSignedTransaction(fields, signature, publicKey) {
|
|
1898
|
-
const n = normalizeTxFields(fields);
|
|
1899
|
-
const sig = expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature");
|
|
1900
|
-
const pk = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
1901
|
-
const w = new BincodeWriter();
|
|
1902
|
-
w.u64(n.chainId);
|
|
1903
|
-
w.u64(n.nonce);
|
|
1904
|
-
w.bytes(uint256Be(n.maxPriorityFeePerGas, "maxPriorityFeePerGas"));
|
|
1905
|
-
w.bytes(uint256Be(n.maxFeePerGas, "maxFeePerGas"));
|
|
1906
|
-
w.u64(n.gasLimit);
|
|
1907
|
-
if (n.to === null) {
|
|
1908
|
-
w.u8(0);
|
|
1909
|
-
} else {
|
|
1910
|
-
w.u8(1);
|
|
1911
|
-
w.bytes(n.to);
|
|
1912
|
-
}
|
|
1913
|
-
w.bytes(uint256Be(n.value, "value"));
|
|
1914
|
-
w.bytes(n.input);
|
|
1915
|
-
w.u64(0n);
|
|
1916
|
-
w.u64(BigInt(n.extensions.length));
|
|
1917
|
-
for (const ext of n.extensions) bincodeTypedExtensionInto(w, ext);
|
|
1918
|
-
bincodeMlDsa65OpaqueInto(w, sig);
|
|
1919
|
-
bincodeMlDsa65OpaqueInto(w, pk);
|
|
1920
|
-
return w.toBytes();
|
|
1921
|
-
}
|
|
1922
|
-
function normalizeTxFields(fields) {
|
|
1923
|
-
return {
|
|
1924
|
-
chainId: parseBigint(fields.chainId, "chainId"),
|
|
1925
|
-
nonce: parseBigint(fields.nonce, "nonce"),
|
|
1926
|
-
maxPriorityFeePerGas: parseBigint(fields.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
1927
|
-
maxFeePerGas: parseBigint(fields.maxFeePerGas, "maxFeePerGas"),
|
|
1928
|
-
gasLimit: parseBigint(fields.gasLimit, "gasLimit"),
|
|
1929
|
-
to: normalizeTo(fields.to),
|
|
1930
|
-
value: parseBigint(fields.value, "value"),
|
|
1931
|
-
input: normalizeBytes(fields.input ?? new Uint8Array(0), "input"),
|
|
1932
|
-
extensions: normalizeExtensions(fields.extensions)
|
|
1933
|
-
};
|
|
1934
|
-
}
|
|
1935
|
-
function normalizeTo(value) {
|
|
1936
|
-
if (value === null) return null;
|
|
1937
|
-
const bytes = normalizeBytes(value, "to");
|
|
1938
|
-
return expectBytes(bytes, 20, "to");
|
|
1939
|
-
}
|
|
1940
|
-
function normalizeBytes(value, label) {
|
|
1941
|
-
if (typeof value === "string") return hexToBytes2(value, label);
|
|
1942
|
-
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
1943
|
-
}
|
|
1944
|
-
function normalizeExtensions(value) {
|
|
1945
|
-
if (value === void 0) return [];
|
|
1946
|
-
return value.map((ext, index) => {
|
|
1947
|
-
if (!Number.isInteger(ext.kind) || ext.kind < 0 || ext.kind > 255) {
|
|
1948
|
-
throw new Error(`extensions[${index}].kind out of u8 range`);
|
|
1949
|
-
}
|
|
1950
|
-
const body = normalizeBytes("bodyHex" in ext ? ext.bodyHex : ext.body, `extensions[${index}].body`);
|
|
1951
|
-
if (body.length > 4294967295) {
|
|
1952
|
-
throw new Error(`extensions[${index}].body exceeds u32 length`);
|
|
1953
|
-
}
|
|
1954
|
-
return { kind: ext.kind, body };
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
function encodeExtensionsForHash(extensions) {
|
|
1958
|
-
const chunks = [bigintToBeBytes(BigInt(extensions.length), 4, "extensions.length")];
|
|
1959
|
-
for (const ext of extensions) {
|
|
1960
|
-
chunks.push(
|
|
1961
|
-
Uint8Array.of(ext.kind),
|
|
1962
|
-
bigintToBeBytes(BigInt(ext.body.length), 4, "extension.body.length"),
|
|
1963
|
-
ext.body
|
|
1964
|
-
);
|
|
1965
|
-
}
|
|
1966
|
-
return concatBytes2(...chunks);
|
|
1967
|
-
}
|
|
1968
|
-
function uint256Be(value, label) {
|
|
1969
|
-
if (value < 0n || value >= 1n << 256n) throw new Error(`${label} out of u256 range`);
|
|
1970
|
-
const out = new Uint8Array(32);
|
|
1971
|
-
let v = value;
|
|
1972
|
-
for (let i = 31; i >= 0; i--) {
|
|
1973
|
-
out[i] = Number(v & 0xffn);
|
|
1974
|
-
v >>= 8n;
|
|
1975
|
-
}
|
|
1976
|
-
return out;
|
|
1977
|
-
}
|
|
1978
|
-
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
1979
|
-
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
1980
|
-
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
1981
|
-
w.bytes(raw);
|
|
1982
|
-
}
|
|
1983
|
-
function bincodeTypedExtensionInto(w, ext) {
|
|
1984
|
-
w.u8(ext.kind);
|
|
1985
|
-
w.bytes(ext.body);
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
// src/crypto/ml-dsa.ts
|
|
1989
|
-
var ML_DSA_65_SEED_LEN = 32;
|
|
1990
|
-
var ML_DSA_65_SIGNING_KEY_LEN = 4032;
|
|
1991
|
-
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
1992
|
-
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
1993
|
-
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
1994
|
-
var ENUM_VARIANT_INDEX_ML_DSA_65 = 3;
|
|
1995
|
-
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
1996
|
-
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
1997
|
-
var MlDsa65Backend = class _MlDsa65Backend {
|
|
1998
|
-
#secretKey;
|
|
1999
|
-
#publicKey;
|
|
2000
|
-
#addressBytes;
|
|
2001
|
-
#disposed = false;
|
|
2002
|
-
constructor(secretKey, publicKey) {
|
|
2003
|
-
this.#secretKey = expectBytes(secretKey, ML_DSA_65_SIGNING_KEY_LEN, "ML-DSA-65 secret key").slice();
|
|
2004
|
-
this.#publicKey = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key").slice();
|
|
2005
|
-
this.#addressBytes = mlDsa65AddressBytes(this.#publicKey);
|
|
2006
|
-
}
|
|
2007
|
-
static fromSeed(seed) {
|
|
2008
|
-
const kp = mlDsa_js.ml_dsa65.keygen(expectBytes(seed, ML_DSA_65_SEED_LEN, "ML-DSA-65 seed"));
|
|
2009
|
-
return new _MlDsa65Backend(kp.secretKey, kp.publicKey);
|
|
2010
|
-
}
|
|
2011
|
-
publicKey() {
|
|
2012
|
-
return this.#publicKey.slice();
|
|
2013
|
-
}
|
|
2014
|
-
addressBytes() {
|
|
2015
|
-
return this.#addressBytes.slice();
|
|
2016
|
-
}
|
|
2017
|
-
getAddress() {
|
|
2018
|
-
return bytesToHex2(this.#addressBytes);
|
|
2019
|
-
}
|
|
2020
|
-
sign(message) {
|
|
2021
|
-
if (this.#disposed) {
|
|
2022
|
-
throw new Error("MlDsa65Backend disposed");
|
|
2023
|
-
}
|
|
2024
|
-
return mlDsa_js.ml_dsa65.sign(message, this.#secretKey, { extraEntropy: false });
|
|
2025
|
-
}
|
|
2026
|
-
/**
|
|
2027
|
-
* Best-effort deterministic wipe of the in-memory secret key. Zeroes the
|
|
2028
|
-
* SDK-held `#secretKey` copy and makes any subsequent `sign()` /
|
|
2029
|
-
* `signPrehash()` / `signEvmTx()` throw `"MlDsa65Backend disposed"` rather
|
|
2030
|
-
* than signing with a zeroed key. Idempotent. Public material
|
|
2031
|
-
* (`publicKey()` / `getAddress()` / `verify()`) stays usable.
|
|
2032
|
-
*
|
|
2033
|
-
* Defense-in-depth (S1-01): narrows the post-lock residency window of the
|
|
2034
|
-
* ML-DSA-65 secret in the JS heap. `@noble/post-quantum`'s internal
|
|
2035
|
-
* transient keygen/sign buffers are out of scope; the SDK-held copy is the
|
|
2036
|
-
* meaningful residency win.
|
|
2037
|
-
*/
|
|
2038
|
-
dispose() {
|
|
2039
|
-
this.#secretKey.fill(0);
|
|
2040
|
-
this.#disposed = true;
|
|
2041
|
-
}
|
|
2042
|
-
/** Alias for {@link dispose}. */
|
|
2043
|
-
zeroize() {
|
|
2044
|
-
this.dispose();
|
|
2045
|
-
}
|
|
2046
|
-
/** Whether {@link dispose} has been called (the secret key is wiped). */
|
|
2047
|
-
get disposed() {
|
|
2048
|
-
return this.#disposed;
|
|
2049
|
-
}
|
|
2050
|
-
signPrehash(digest) {
|
|
2051
|
-
return this.sign(expectBytes(digest, 32, "prehash"));
|
|
2052
|
-
}
|
|
2053
|
-
verify(message, signature) {
|
|
2054
|
-
return mlDsa_js.ml_dsa65.verify(
|
|
2055
|
-
expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature"),
|
|
2056
|
-
message,
|
|
2057
|
-
this.#publicKey
|
|
2058
|
-
);
|
|
2059
|
-
}
|
|
2060
|
-
signEvmTx(fields) {
|
|
2061
|
-
const txHashPreimage = encodeTransactionForHash(fields, 1);
|
|
2062
|
-
const sighash = sha3_js.keccak_256(txHashPreimage);
|
|
2063
|
-
const signature = this.sign(sighash);
|
|
2064
|
-
const wireBytes = bincodeSignedTransaction(fields, signature, this.#publicKey);
|
|
2065
|
-
const txHash = sha3_js.keccak_256(
|
|
2066
|
-
concatBytes2(
|
|
2067
|
-
encodeTransactionForHash(fields, 2),
|
|
2068
|
-
signature,
|
|
2069
|
-
this.#publicKey
|
|
2070
|
-
)
|
|
2071
|
-
);
|
|
2072
|
-
return {
|
|
2073
|
-
wireHex: bytesToHex2(wireBytes).slice(2),
|
|
2074
|
-
wireBytes,
|
|
2075
|
-
sighash,
|
|
2076
|
-
txHash
|
|
2077
|
-
};
|
|
2078
|
-
}
|
|
2079
|
-
};
|
|
2080
|
-
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
2081
|
-
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
2082
|
-
}
|
|
2083
|
-
function mlDsa65AddressBytes(publicKey) {
|
|
2084
|
-
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
2085
|
-
return blake3_js.blake3(concatBytes2(
|
|
2086
|
-
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
2087
|
-
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
2088
|
-
bytes
|
|
2089
|
-
)).slice(0, 20);
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
// src/crypto/envelope.ts
|
|
2093
|
-
new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
2094
|
-
var MempoolClass = {
|
|
2095
|
-
Transfer: 0,
|
|
2096
|
-
ContractCall: 1,
|
|
2097
|
-
CLOBOp: 3};
|
|
2098
|
-
function bincodeNonceAad(aad) {
|
|
2099
|
-
const w = new BincodeWriter();
|
|
2100
|
-
w.bytes(expectBytes(aad.sender, 20, "NonceAad.sender"));
|
|
2101
|
-
w.u64(aad.nonce);
|
|
2102
|
-
w.u64(aad.chainId);
|
|
2103
|
-
w.enumVariant(aad.class);
|
|
2104
|
-
w.u128(aad.maxFeePerGas);
|
|
2105
|
-
w.u128(aad.maxPriorityFeePerGas);
|
|
2106
|
-
w.u64(aad.gasLimit);
|
|
2107
|
-
return w.toBytes();
|
|
2108
|
-
}
|
|
2109
|
-
function bincodeDecryptHint(hint) {
|
|
2110
|
-
const w = new BincodeWriter();
|
|
2111
|
-
w.u64(hint.epoch);
|
|
2112
|
-
w.u16(hint.scheme);
|
|
2113
|
-
return w.toBytes();
|
|
2114
|
-
}
|
|
2115
|
-
function bincodeEncryptedEnvelope(env) {
|
|
2116
|
-
const w = new BincodeWriter();
|
|
2117
|
-
w.rawBytes(bincodeNonceAad(env.nonceAad));
|
|
2118
|
-
w.bytes(env.ciphertext);
|
|
2119
|
-
w.rawBytes(bincodeDecryptHint(env.decryptionHint));
|
|
2120
|
-
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"));
|
|
2121
|
-
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"));
|
|
2122
|
-
w.bytes(expectBytes(env.sender, 20, "sender"));
|
|
2123
|
-
return w.toBytes();
|
|
2124
|
-
}
|
|
2125
|
-
function outerSigDigest(nonceAad, ciphertext, decryptionHint, senderPubkey) {
|
|
2126
|
-
const aad = bincodeNonceAad(nonceAad);
|
|
2127
|
-
const hint = bincodeDecryptHint(decryptionHint);
|
|
2128
|
-
return sha3_js.keccak_256(concatBytes2(aad, ciphertext, hint, expectBytes(senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey")));
|
|
2129
|
-
}
|
|
2130
|
-
function bincodeMlDsa65OpaqueInto2(w, raw) {
|
|
2131
|
-
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
2132
|
-
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
2133
|
-
w.bytes(raw);
|
|
2134
|
-
}
|
|
2135
|
-
var SEAL_EK_LEN = 1184;
|
|
2136
|
-
var SEAL_KEY_LEN = 32;
|
|
2137
|
-
var SEAL_NONCE_LEN = 12;
|
|
2138
|
-
var SEAL_COMMIT_LEN = 32;
|
|
2139
|
-
var SEAL_SECRET_LEN = 32;
|
|
2140
|
-
var SEAL_SHARE_LEN = 1 + SEAL_SECRET_LEN;
|
|
2141
|
-
var CLUSTER_MLKEM_SHAMIR = 3;
|
|
2142
|
-
var COMMIT_DOMAIN = new TextEncoder().encode("lythiumseal/commit/v1");
|
|
2143
|
-
var KEK_DOMAIN = new TextEncoder().encode("lythiumseal/kek/v1");
|
|
2144
|
-
var NONCE_DOMAIN = new TextEncoder().encode("lythiumseal/nonce/v1");
|
|
2145
|
-
var BODY_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/body/v1");
|
|
2146
|
-
var SHARE_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/share/v1");
|
|
2147
|
-
var ROSTER_DOMAIN = new TextEncoder().encode("lythiumseal/roster/v1");
|
|
2148
|
-
function cryptoRandomSource() {
|
|
2149
|
-
return {
|
|
2150
|
-
fillBytes(dest) {
|
|
2151
|
-
crypto.getRandomValues(dest);
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
}
|
|
2155
|
-
function u32le(n) {
|
|
2156
|
-
const out = new Uint8Array(4);
|
|
2157
|
-
out[0] = n & 255;
|
|
2158
|
-
out[1] = n >>> 8 & 255;
|
|
2159
|
-
out[2] = n >>> 16 & 255;
|
|
2160
|
-
out[3] = n >>> 24 & 255;
|
|
2161
|
-
return out;
|
|
2162
|
-
}
|
|
2163
|
-
function u64le(n) {
|
|
2164
|
-
const out = new Uint8Array(8);
|
|
2165
|
-
let v = n;
|
|
2166
|
-
for (let i = 0; i < 8; i++) {
|
|
2167
|
-
out[i] = Number(v & 0xffn);
|
|
2168
|
-
v >>= 8n;
|
|
2169
|
-
}
|
|
2170
|
-
return out;
|
|
2171
|
-
}
|
|
2172
|
-
function framed(field2) {
|
|
2173
|
-
return concatBytes2(u32le(field2.length), field2);
|
|
2174
|
-
}
|
|
2175
|
-
function keyCommitment(key) {
|
|
2176
|
-
return sha3_js.shake256(concatBytes2(framed(COMMIT_DOMAIN), key), { dkLen: SEAL_COMMIT_LEN });
|
|
2177
|
-
}
|
|
2178
|
-
function deriveKek(sharedSecret, domain, clusterId, epoch, opIndex) {
|
|
2179
|
-
const input = concatBytes2(
|
|
2180
|
-
framed(KEK_DOMAIN),
|
|
2181
|
-
framed(sharedSecret),
|
|
2182
|
-
framed(domain),
|
|
2183
|
-
u32le(clusterId),
|
|
2184
|
-
u64le(epoch),
|
|
2185
|
-
Uint8Array.of(opIndex)
|
|
2186
|
-
);
|
|
2187
|
-
return sha3_js.shake256(input, { dkLen: SEAL_KEY_LEN });
|
|
2188
|
-
}
|
|
2189
|
-
function deriveNonce(domain, context) {
|
|
2190
|
-
const input = concatBytes2(framed(NONCE_DOMAIN), framed(domain), framed(context));
|
|
2191
|
-
return sha3_js.shake256(input, { dkLen: SEAL_NONCE_LEN });
|
|
2192
|
-
}
|
|
2193
|
-
function bodyAad(ctx, k, n) {
|
|
2194
|
-
return concatBytes2(
|
|
2195
|
-
BODY_AAD_DOMAIN,
|
|
2196
|
-
u32le(ctx.clusterId),
|
|
2197
|
-
u64le(ctx.epoch),
|
|
2198
|
-
Uint8Array.of(k),
|
|
2199
|
-
Uint8Array.of(n),
|
|
2200
|
-
ctx.rosterHash
|
|
2201
|
-
);
|
|
2202
|
-
}
|
|
2203
|
-
function shareAad(ctx, opIndex) {
|
|
2204
|
-
return concatBytes2(
|
|
2205
|
-
SHARE_AAD_DOMAIN,
|
|
2206
|
-
u32le(ctx.clusterId),
|
|
2207
|
-
u64le(ctx.epoch),
|
|
2208
|
-
Uint8Array.of(opIndex),
|
|
2209
|
-
ctx.rosterHash
|
|
2210
|
-
);
|
|
2211
|
-
}
|
|
2212
|
-
function aeadSeal(key, nonce, plaintext, aad) {
|
|
2213
|
-
const cipher = chacha_js.chacha20poly1305(key, nonce, aad);
|
|
2214
|
-
const ct = cipher.encrypt(plaintext);
|
|
2215
|
-
return { nonce, ct, commitment: keyCommitment(key) };
|
|
2216
|
-
}
|
|
2217
|
-
function gfMul(a, b) {
|
|
2218
|
-
let product = 0;
|
|
2219
|
-
let x = a & 255;
|
|
2220
|
-
let y = b & 255;
|
|
2221
|
-
for (let i = 0; i < 8; i++) {
|
|
2222
|
-
const mask = -(y & 1) & 255;
|
|
2223
|
-
product ^= x & mask;
|
|
2224
|
-
const high = -(x >> 7 & 1) & 255;
|
|
2225
|
-
x = x << 1 & 255;
|
|
2226
|
-
x ^= 27 & high;
|
|
2227
|
-
y >>= 1;
|
|
2228
|
-
}
|
|
2229
|
-
return product & 255;
|
|
2230
|
-
}
|
|
2231
|
-
function polyEval(coeffs, x) {
|
|
2232
|
-
let acc = 0;
|
|
2233
|
-
for (let i = coeffs.length - 1; i >= 0; i--) {
|
|
2234
|
-
acc = gfMul(acc, x) ^ coeffs[i];
|
|
2235
|
-
}
|
|
2236
|
-
return acc & 255;
|
|
2237
|
-
}
|
|
2238
|
-
function shamirSplit(secret, t, n, rng) {
|
|
2239
|
-
const byteCoeffs = [];
|
|
2240
|
-
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
2241
|
-
const c = new Uint8Array(t);
|
|
2242
|
-
c[0] = secret[j];
|
|
2243
|
-
if (t > 1) {
|
|
2244
|
-
const tail = new Uint8Array(t - 1);
|
|
2245
|
-
rng.fillBytes(tail);
|
|
2246
|
-
c.set(tail, 1);
|
|
2247
|
-
}
|
|
2248
|
-
byteCoeffs.push(c);
|
|
2249
|
-
}
|
|
2250
|
-
const shares = [];
|
|
2251
|
-
for (let k = 0; k < n; k++) {
|
|
2252
|
-
const x = k + 1 & 255;
|
|
2253
|
-
const value = new Uint8Array(SEAL_SECRET_LEN);
|
|
2254
|
-
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
2255
|
-
value[j] = polyEval(byteCoeffs[j], x);
|
|
2256
|
-
}
|
|
2257
|
-
shares.push({ index: x, value });
|
|
2258
|
-
}
|
|
2259
|
-
return shares;
|
|
2260
|
-
}
|
|
2261
|
-
function shareToBytes(s) {
|
|
2262
|
-
const out = new Uint8Array(SEAL_SHARE_LEN);
|
|
2263
|
-
out[0] = s.index;
|
|
2264
|
-
out.set(s.value, 1);
|
|
2265
|
-
return out;
|
|
2266
|
-
}
|
|
2267
|
-
function sealRosterHash(keccak2562, clusterId, t, n, roster) {
|
|
2268
|
-
const chunks = [ROSTER_DOMAIN, u32le(clusterId), Uint8Array.of(t), Uint8Array.of(n)];
|
|
2269
|
-
for (const { operatorIndex, ek } of roster) {
|
|
2270
|
-
chunks.push(Uint8Array.of(operatorIndex), ek);
|
|
2271
|
-
}
|
|
2272
|
-
return keccak2562(concatBytes2(...chunks));
|
|
2273
|
-
}
|
|
2274
|
-
function encodeSealEnvelope(env) {
|
|
2275
|
-
const chunks = [];
|
|
2276
|
-
chunks.push(u32le(env.clusterId));
|
|
2277
|
-
chunks.push(u64le(env.epoch));
|
|
2278
|
-
chunks.push(expectBytes(env.rosterHash, 32, "rosterHash"));
|
|
2279
|
-
chunks.push(Uint8Array.of(env.t));
|
|
2280
|
-
chunks.push(Uint8Array.of(env.n));
|
|
2281
|
-
pushAeadBody(chunks, env.aeadBody);
|
|
2282
|
-
chunks.push(u64le(BigInt(env.recipients.length)));
|
|
2283
|
-
for (const r of env.recipients) {
|
|
2284
|
-
chunks.push(Uint8Array.of(r.operatorIndex));
|
|
2285
|
-
chunks.push(u64le(BigInt(r.kemCt.length)));
|
|
2286
|
-
chunks.push(r.kemCt);
|
|
2287
|
-
pushAeadBody(chunks, r.wrapped);
|
|
2288
|
-
}
|
|
2289
|
-
return concatBytes2(...chunks);
|
|
2290
|
-
}
|
|
2291
|
-
function pushAeadBody(chunks, body) {
|
|
2292
|
-
chunks.push(expectBytes(body.nonce, SEAL_NONCE_LEN, "aead nonce"));
|
|
2293
|
-
chunks.push(u64le(BigInt(body.ct.length)));
|
|
2294
|
-
chunks.push(body.ct);
|
|
2295
|
-
chunks.push(expectBytes(body.commitment, SEAL_COMMIT_LEN, "aead commitment"));
|
|
2296
|
-
}
|
|
2297
|
-
function sealToCluster(args) {
|
|
2298
|
-
const { plaintext, recipientEks, t, clusterId } = args;
|
|
2299
|
-
const epoch = args.epoch;
|
|
2300
|
-
const rosterHash = expectBytes(args.rosterHash, 32, "rosterHash");
|
|
2301
|
-
const rng = args.rng ?? cryptoRandomSource();
|
|
2302
|
-
const n = recipientEks.length;
|
|
2303
|
-
if (!Number.isInteger(t) || t < 1 || t > n || n < 1 || n > 255) {
|
|
2304
|
-
throw new Error(`invalid threshold/recipient count: t=${t} n=${n}`);
|
|
2305
|
-
}
|
|
2306
|
-
for (let i = 0; i < n; i++) {
|
|
2307
|
-
expectBytes(recipientEks[i], SEAL_EK_LEN, `recipientEks[${i}]`);
|
|
2308
|
-
}
|
|
2309
|
-
const ctx = { clusterId, epoch, rosterHash };
|
|
2310
|
-
const bodyKey = new Uint8Array(SEAL_KEY_LEN);
|
|
2311
|
-
rng.fillBytes(bodyKey);
|
|
2312
|
-
const aad = bodyAad(ctx, t, n);
|
|
2313
|
-
const bodyNonce = deriveNonce(new TextEncoder().encode("body"), aad);
|
|
2314
|
-
const aeadBody = aeadSeal(bodyKey, bodyNonce, plaintext, aad);
|
|
2315
|
-
const shares = shamirSplit(bodyKey, t, n, rng);
|
|
2316
|
-
const recipients = [];
|
|
2317
|
-
for (let i = 0; i < n; i++) {
|
|
2318
|
-
const opIndex = i + 1 & 255;
|
|
2319
|
-
const m = new Uint8Array(32);
|
|
2320
|
-
rng.fillBytes(m);
|
|
2321
|
-
const { cipherText: kemCt, sharedSecret } = mlKem_js.ml_kem768.encapsulate(recipientEks[i], m);
|
|
2322
|
-
const kek = deriveKek(sharedSecret, rosterHash, clusterId, epoch, opIndex);
|
|
2323
|
-
const sAad = shareAad(ctx, opIndex);
|
|
2324
|
-
const wrapNonce = deriveNonce(new TextEncoder().encode("share"), sAad);
|
|
2325
|
-
const wrapped = aeadSeal(kek, wrapNonce, shareToBytes(shares[i]), sAad);
|
|
2326
|
-
recipients.push({ operatorIndex: opIndex, kemCt, wrapped });
|
|
2327
|
-
sharedSecret.fill(0);
|
|
2328
|
-
kek.fill(0);
|
|
2329
|
-
}
|
|
2330
|
-
bodyKey.fill(0);
|
|
2331
|
-
return {
|
|
2332
|
-
clusterId,
|
|
2333
|
-
epoch,
|
|
2334
|
-
rosterHash,
|
|
2335
|
-
t,
|
|
2336
|
-
n,
|
|
2337
|
-
aeadBody,
|
|
2338
|
-
recipients
|
|
2339
|
-
};
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
// src/crypto/seal.ts
|
|
2343
|
-
var CLUSTER_MLKEM_SHAMIR_ALGO = "cluster-mlkem768-shamir";
|
|
2344
|
-
function parseClusterSealKeys(source) {
|
|
2345
|
-
const n = source.roster.length;
|
|
2346
|
-
if (n === 0) {
|
|
2347
|
-
throw new Error("cluster seal roster is empty");
|
|
2348
|
-
}
|
|
2349
|
-
if (source.n !== n) {
|
|
2350
|
-
throw new Error(`cluster seal roster n=${source.n} disagrees with ${n} entries`);
|
|
2351
|
-
}
|
|
2352
|
-
if (!Number.isInteger(source.t) || source.t < 2 || source.t > n) {
|
|
2353
|
-
throw new Error(`cluster seal threshold t=${source.t} out of range 2..=${n}`);
|
|
2354
|
-
}
|
|
2355
|
-
const sorted = [...source.roster].sort((a, b) => a.operatorIndex - b.operatorIndex);
|
|
2356
|
-
const recipientEks = [];
|
|
2357
|
-
const hashInput = [];
|
|
2358
|
-
for (let i = 0; i < n; i++) {
|
|
2359
|
-
const entry = sorted[i];
|
|
2360
|
-
if (entry.operatorIndex !== i + 1) {
|
|
2361
|
-
throw new Error(
|
|
2362
|
-
`cluster seal roster operator indices must be 1..=${n}; got ${entry.operatorIndex} at slot ${i + 1}`
|
|
2363
|
-
);
|
|
2364
|
-
}
|
|
2365
|
-
const ek = expectBytes(hexToBytes2(entry.mlKemEk, `operator ${entry.operatorIndex} mlKemEk`), SEAL_EK_LEN, `operator ${entry.operatorIndex} ek`);
|
|
2366
|
-
recipientEks.push(ek);
|
|
2367
|
-
hashInput.push({ operatorIndex: entry.operatorIndex, ek });
|
|
2368
|
-
}
|
|
2369
|
-
const recomputed = sealRosterHash(keccak256, source.clusterId, source.t, n, hashInput);
|
|
2370
|
-
if (source.rosterHash !== void 0) {
|
|
2371
|
-
const supplied = expectBytes(hexToBytes2(source.rosterHash, "rosterHash"), 32, "rosterHash");
|
|
2372
|
-
if (!bytesEqual(supplied, recomputed)) {
|
|
2373
|
-
throw new Error(
|
|
2374
|
-
`cluster seal roster hash mismatch: source ${bytesToHex2(supplied)} != recomputed ${bytesToHex2(recomputed)} (the roster hash does not commit to this ek set)`
|
|
2375
|
-
);
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
return {
|
|
2379
|
-
algo: source.algo ?? CLUSTER_MLKEM_SHAMIR_ALGO,
|
|
2380
|
-
clusterId: source.clusterId,
|
|
2381
|
-
epoch: toBigInt(source.epoch),
|
|
2382
|
-
rosterHash: recomputed,
|
|
2383
|
-
t: source.t,
|
|
2384
|
-
n,
|
|
2385
|
-
recipientEks
|
|
2386
|
-
};
|
|
2387
|
-
}
|
|
2388
|
-
async function sealTransaction(args) {
|
|
2389
|
-
const keys = args.clusterSealKeys;
|
|
2390
|
-
const senderPubkey = expectBytes(args.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey");
|
|
2391
|
-
const senderAddress = expectBytes(args.senderAddress, 20, "senderAddress");
|
|
2392
|
-
const env = sealToCluster({
|
|
2393
|
-
plaintext: args.signedTxBincode,
|
|
2394
|
-
recipientEks: keys.recipientEks,
|
|
2395
|
-
t: keys.t,
|
|
2396
|
-
clusterId: keys.clusterId,
|
|
2397
|
-
epoch: keys.epoch,
|
|
2398
|
-
rosterHash: keys.rosterHash,
|
|
2399
|
-
rng: args.rng
|
|
2400
|
-
});
|
|
2401
|
-
const ciphertext = encodeSealEnvelope(env);
|
|
2402
|
-
const decryptionHint = { epoch: keys.epoch, scheme: CLUSTER_MLKEM_SHAMIR };
|
|
2403
|
-
const digest = outerSigDigest(args.aad, ciphertext, decryptionHint, senderPubkey);
|
|
2404
|
-
const outerSignature = expectBytes(
|
|
2405
|
-
await args.signOuterDigest(digest),
|
|
2406
|
-
ML_DSA_65_SIGNATURE_LEN,
|
|
2407
|
-
"outerSignature"
|
|
2408
|
-
);
|
|
2409
|
-
const envelope = {
|
|
2410
|
-
nonceAad: args.aad,
|
|
2411
|
-
ciphertext,
|
|
2412
|
-
decryptionHint,
|
|
2413
|
-
senderPubkey,
|
|
2414
|
-
outerSignature,
|
|
2415
|
-
sender: senderAddress
|
|
2416
|
-
};
|
|
2417
|
-
const envelopeWireBytes = bincodeEncryptedEnvelope(envelope);
|
|
2418
|
-
return {
|
|
2419
|
-
envelopeWireHex: `0x${bytesToHex2(envelopeWireBytes).slice(2)}`,
|
|
2420
|
-
envelopeWireBytes,
|
|
2421
|
-
ciphertextBytes: ciphertext.length
|
|
2422
|
-
};
|
|
2423
|
-
}
|
|
2424
|
-
function keccak256(input) {
|
|
2425
|
-
return sha3_js.keccak_256(input);
|
|
2426
|
-
}
|
|
2427
|
-
function toBigInt(value) {
|
|
2428
|
-
if (typeof value === "bigint") return value;
|
|
2429
|
-
return BigInt(value);
|
|
2430
|
-
}
|
|
2431
|
-
function bytesEqual(a, b) {
|
|
2432
|
-
if (a.length !== b.length) return false;
|
|
2433
|
-
for (let i = 0; i < a.length; i++) {
|
|
2434
|
-
if (a[i] !== b[i]) return false;
|
|
2435
|
-
}
|
|
2436
|
-
return true;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
// src/crypto/submission.ts
|
|
2440
|
-
async function fetchEncryptionKey(client) {
|
|
2441
|
-
const result = await client.call(
|
|
2442
|
-
"lyth_getEncryptionKey",
|
|
2443
|
-
[]
|
|
2444
|
-
);
|
|
2445
|
-
return {
|
|
2446
|
-
algo: result.algo ?? "ml-kem-768",
|
|
2447
|
-
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
2448
|
-
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
2449
|
-
};
|
|
2450
|
-
}
|
|
2451
|
-
var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "private submission requires cluster seal keys; pass clusterSealKeysSource or enable lyth_getClusterSealKeys";
|
|
2452
|
-
async function buildEncryptedSubmission(args) {
|
|
2453
|
-
const signed = args.backend.signEvmTx(args.tx);
|
|
2454
|
-
const clusterSealKeys = await resolveClusterSealKeys(args);
|
|
2455
|
-
const aad = nonceAadForTx(args.tx, args.backend.addressBytes(), args.class);
|
|
2456
|
-
const sealed = await sealTransaction({
|
|
2457
|
-
signedTxBincode: signed.wireBytes,
|
|
2458
|
-
clusterSealKeys,
|
|
2459
|
-
aad,
|
|
2460
|
-
senderAddress: args.backend.addressBytes(),
|
|
2461
|
-
senderPubkey: args.backend.publicKey(),
|
|
2462
|
-
signOuterDigest: (digest) => args.backend.signPrehash(digest)
|
|
2463
|
-
});
|
|
2464
|
-
return {
|
|
2465
|
-
envelopeWireHex: sealed.envelopeWireHex,
|
|
2466
|
-
innerSighashHex: bytesToHex2(signed.sighash),
|
|
2467
|
-
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
2468
|
-
innerWireBytes: signed.wireBytes.length
|
|
2469
|
-
};
|
|
2470
|
-
}
|
|
2471
|
-
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
2472
|
-
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
2473
|
-
}
|
|
2474
|
-
function buildPlaintextSubmission(args) {
|
|
2475
|
-
const signed = args.backend.signEvmTx(args.tx);
|
|
2476
|
-
return {
|
|
2477
|
-
signedTxWireHex: `0x${signed.wireHex}`,
|
|
2478
|
-
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
2479
|
-
innerSighashHex: bytesToHex2(signed.sighash),
|
|
2480
|
-
innerWireBytes: signed.wireBytes.length
|
|
2481
|
-
};
|
|
2482
|
-
}
|
|
2483
|
-
async function submitPlaintextTransaction(client, signedTxWireHex, expectedTxHashHex) {
|
|
2484
|
-
const returned = await client.call("mesh_submitTx", [signedTxWireHex]);
|
|
2485
|
-
const returnedBytes = hexToBytes2(returned, "mesh_submitTx tx hash");
|
|
2486
|
-
if (returnedBytes.length !== 32) {
|
|
2487
|
-
throw new Error(
|
|
2488
|
-
`mesh_submitTx tx hash must be 32 bytes, got ${returnedBytes.length}`
|
|
2489
|
-
);
|
|
2490
|
-
}
|
|
2491
|
-
const expectedBytes = hexToBytes2(expectedTxHashHex, "expected tx hash");
|
|
2492
|
-
if (!bytesEqual2(returnedBytes, expectedBytes)) {
|
|
2493
|
-
throw new Error(
|
|
2494
|
-
`mesh_submitTx returned tx hash ${bytesToHex2(returnedBytes)} but the locally computed canonical hash is ${bytesToHex2(expectedBytes)}`
|
|
2495
|
-
);
|
|
2496
|
-
}
|
|
2497
|
-
return bytesToHex2(returnedBytes);
|
|
2498
|
-
}
|
|
2499
|
-
function bytesEqual2(a, b) {
|
|
2500
|
-
if (a.length !== b.length) return false;
|
|
2501
|
-
for (let i = 0; i < a.length; i++) {
|
|
2502
|
-
if (a[i] !== b[i]) return false;
|
|
2503
|
-
}
|
|
2504
|
-
return true;
|
|
2505
|
-
}
|
|
2506
|
-
async function resolveClusterSealKeys(args) {
|
|
2507
|
-
if (args.clusterSealKeys !== void 0) return args.clusterSealKeys;
|
|
2508
|
-
if (args.clusterSealKeysSource !== void 0) {
|
|
2509
|
-
return parseClusterSealKeys(args.clusterSealKeysSource);
|
|
2510
|
-
}
|
|
2511
|
-
if (args.client === void 0) {
|
|
2512
|
-
throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
|
|
2513
|
-
}
|
|
2514
|
-
const clusterId = args.clusterId ?? 0;
|
|
2515
|
-
const result = await args.client.call(
|
|
2516
|
-
"lyth_getClusterSealKeys",
|
|
2517
|
-
[clusterId]
|
|
2518
|
-
);
|
|
2519
|
-
return parseClusterSealKeys({ ...result, clusterId: result.clusterId ?? clusterId });
|
|
2520
|
-
}
|
|
2521
|
-
function nonceAadForTx(tx, sender, mempoolClass) {
|
|
2522
|
-
return {
|
|
2523
|
-
sender,
|
|
2524
|
-
nonce: parseBigint(tx.nonce, "nonce"),
|
|
2525
|
-
chainId: parseBigint(tx.chainId, "chainId"),
|
|
2526
|
-
class: mempoolClass ?? inferMempoolClass(tx),
|
|
2527
|
-
maxFeePerGas: parseBigint(tx.maxFeePerGas, "maxFeePerGas"),
|
|
2528
|
-
maxPriorityFeePerGas: parseBigint(tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
2529
|
-
gasLimit: parseBigint(tx.gasLimit, "gasLimit")
|
|
2530
|
-
};
|
|
2531
|
-
}
|
|
2532
|
-
function inferMempoolClass(tx) {
|
|
2533
|
-
if (tx.to === null || hasInput(tx.input)) return MempoolClass.ContractCall;
|
|
2534
|
-
return MempoolClass.Transfer;
|
|
2535
|
-
}
|
|
2536
|
-
function hasInput(input) {
|
|
2537
|
-
if (input === void 0) return false;
|
|
2538
|
-
if (typeof input === "string") {
|
|
2539
|
-
const stripped = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
|
|
2540
|
-
return stripped.length > 0;
|
|
2541
|
-
}
|
|
2542
|
-
return input.length > 0;
|
|
2543
|
-
}
|
|
2544
|
-
|
|
2545
2118
|
// src/mrv.ts
|
|
2546
2119
|
var MRV_FORMAT_VERSION = 1;
|
|
2547
2120
|
var MRV_DEPLOY_PAYLOAD_VERSION = 1;
|
|
@@ -3029,29 +2602,28 @@ function buildMrvNativeFeePreview(executionUnitLimit, maxExecutionFeeLythoshi, p
|
|
|
3029
2602
|
async function submitMrvDeployNativeTx(client, backend, artifactBytes, options) {
|
|
3030
2603
|
const plan = buildMrvDeployNativeTxPlan(artifactBytes, options);
|
|
3031
2604
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
3032
|
-
return
|
|
2605
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
3033
2606
|
}
|
|
3034
2607
|
async function submitMrvDeployPayloadNativeTx(client, backend, artifactBytes, options) {
|
|
3035
2608
|
const plan = buildMrvDeployPayloadNativeTxPlan(artifactBytes, options);
|
|
3036
2609
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
3037
|
-
return
|
|
2610
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
3038
2611
|
}
|
|
3039
2612
|
async function submitMrvCallNativeTx(client, backend, contractAddress, input, options) {
|
|
3040
2613
|
const plan = buildMrvCallNativeTxPlan(contractAddress, input, options);
|
|
3041
2614
|
assertMrvCallNativeSubmissionPlan(plan);
|
|
3042
|
-
return
|
|
3043
|
-
}
|
|
3044
|
-
async function
|
|
3045
|
-
const submission =
|
|
3046
|
-
backend,
|
|
3047
|
-
tx: plan.tx,
|
|
3048
|
-
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
3049
|
-
class: options.class
|
|
3050
|
-
});
|
|
2615
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
2616
|
+
}
|
|
2617
|
+
async function submitMrvPlaintextNativeTx(client, backend, plan) {
|
|
2618
|
+
const submission = buildPlaintextSubmission({ backend, tx: plan.tx });
|
|
3051
2619
|
return {
|
|
3052
2620
|
...plan,
|
|
3053
2621
|
...submission,
|
|
3054
|
-
txHash: await
|
|
2622
|
+
txHash: await submitPlaintextTransaction(
|
|
2623
|
+
client,
|
|
2624
|
+
submission.signedTxWireHex,
|
|
2625
|
+
submission.innerTxHashHex
|
|
2626
|
+
)
|
|
3055
2627
|
};
|
|
3056
2628
|
}
|
|
3057
2629
|
function assertMrvNativeSubmissionEnvelope(plan) {
|
|
@@ -3355,50 +2927,264 @@ function validateExecutionUnitLimit(field2, value) {
|
|
|
3355
2927
|
if (value !== void 0 && BigInt(value) === 0n) {
|
|
3356
2928
|
throw new MrvValidationError(`${field2} must be greater than zero`);
|
|
3357
2929
|
}
|
|
3358
|
-
}
|
|
3359
|
-
function normalizeU64(value, field2) {
|
|
3360
|
-
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
3361
|
-
throw new MrvValidationError(`${field2} must be a safe unsigned integer`);
|
|
2930
|
+
}
|
|
2931
|
+
function normalizeU64(value, field2) {
|
|
2932
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
2933
|
+
throw new MrvValidationError(`${field2} must be a safe unsigned integer`);
|
|
2934
|
+
}
|
|
2935
|
+
const out = BigInt(value);
|
|
2936
|
+
if (out < 0n || out > 0xffffffffffffffffn) {
|
|
2937
|
+
throw new MrvValidationError(`${field2} must fit in u64`);
|
|
2938
|
+
}
|
|
2939
|
+
return out;
|
|
2940
|
+
}
|
|
2941
|
+
function validateHexLength(field2, value, expected) {
|
|
2942
|
+
const bytes = hexToBytes3(value, field2);
|
|
2943
|
+
if (bytes.length !== expected) throw new MrvValidationError(`${field2} must be ${expected} bytes`);
|
|
2944
|
+
}
|
|
2945
|
+
function bytesFrom(value, field2) {
|
|
2946
|
+
if (typeof value === "string") return hexToBytes3(value, field2);
|
|
2947
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2948
|
+
}
|
|
2949
|
+
function hexToBytes3(value, field2) {
|
|
2950
|
+
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
2951
|
+
throw new MrvValidationError(`${field2} must be 0x-prefixed even-length hex`);
|
|
2952
|
+
}
|
|
2953
|
+
const out = new Uint8Array((value.length - 2) / 2);
|
|
2954
|
+
for (let i = 0; i < out.length; i++) {
|
|
2955
|
+
out[i] = Number.parseInt(value.slice(2 + i * 2, 4 + i * 2), 16);
|
|
2956
|
+
}
|
|
2957
|
+
return out;
|
|
2958
|
+
}
|
|
2959
|
+
function bytesToHex3(bytes) {
|
|
2960
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2961
|
+
}
|
|
2962
|
+
function concatBytes3(...parts) {
|
|
2963
|
+
const len = parts.reduce((sum, item) => sum + item.length, 0);
|
|
2964
|
+
const out = new Uint8Array(len);
|
|
2965
|
+
let offset = 0;
|
|
2966
|
+
for (const part of parts) {
|
|
2967
|
+
out.set(part, offset);
|
|
2968
|
+
offset += part.length;
|
|
2969
|
+
}
|
|
2970
|
+
return out;
|
|
2971
|
+
}
|
|
2972
|
+
function isIdentifier(value) {
|
|
2973
|
+
return /^[a-z][a-z0-9_]*$/.test(value);
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
// src/crypto/tx.ts
|
|
2977
|
+
function encodeTransactionForHash(fields, tag) {
|
|
2978
|
+
const n = normalizeTxFields(fields);
|
|
2979
|
+
return concatBytes2(
|
|
2980
|
+
Uint8Array.of(tag),
|
|
2981
|
+
bigintToBeBytes(n.chainId, 8, "chainId"),
|
|
2982
|
+
bigintToBeBytes(n.nonce, 8, "nonce"),
|
|
2983
|
+
bigintToBeBytes(n.maxPriorityFeePerGas, 32, "maxPriorityFeePerGas"),
|
|
2984
|
+
bigintToBeBytes(n.maxFeePerGas, 32, "maxFeePerGas"),
|
|
2985
|
+
bigintToBeBytes(n.gasLimit, 8, "gasLimit"),
|
|
2986
|
+
n.to === null ? Uint8Array.of(0) : concatBytes2(Uint8Array.of(1), n.to),
|
|
2987
|
+
bigintToBeBytes(n.value, 32, "value"),
|
|
2988
|
+
bigintToBeBytes(BigInt(n.input.length), 4, "input.length"),
|
|
2989
|
+
n.input,
|
|
2990
|
+
new Uint8Array(4),
|
|
2991
|
+
// access_list length
|
|
2992
|
+
encodeExtensionsForHash(n.extensions)
|
|
2993
|
+
);
|
|
2994
|
+
}
|
|
2995
|
+
function bincodeSignedTransaction(fields, signature, publicKey) {
|
|
2996
|
+
const n = normalizeTxFields(fields);
|
|
2997
|
+
const sig = expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature");
|
|
2998
|
+
const pk = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
2999
|
+
const w = new BincodeWriter();
|
|
3000
|
+
w.u64(n.chainId);
|
|
3001
|
+
w.u64(n.nonce);
|
|
3002
|
+
w.bytes(uint256Be(n.maxPriorityFeePerGas, "maxPriorityFeePerGas"));
|
|
3003
|
+
w.bytes(uint256Be(n.maxFeePerGas, "maxFeePerGas"));
|
|
3004
|
+
w.u64(n.gasLimit);
|
|
3005
|
+
if (n.to === null) {
|
|
3006
|
+
w.u8(0);
|
|
3007
|
+
} else {
|
|
3008
|
+
w.u8(1);
|
|
3009
|
+
w.bytes(n.to);
|
|
3010
|
+
}
|
|
3011
|
+
w.bytes(uint256Be(n.value, "value"));
|
|
3012
|
+
w.bytes(n.input);
|
|
3013
|
+
w.u64(0n);
|
|
3014
|
+
w.u64(BigInt(n.extensions.length));
|
|
3015
|
+
for (const ext of n.extensions) bincodeTypedExtensionInto(w, ext);
|
|
3016
|
+
bincodeMlDsa65OpaqueInto(w, sig);
|
|
3017
|
+
bincodeMlDsa65OpaqueInto(w, pk);
|
|
3018
|
+
return w.toBytes();
|
|
3019
|
+
}
|
|
3020
|
+
function normalizeTxFields(fields) {
|
|
3021
|
+
return {
|
|
3022
|
+
chainId: parseBigint(fields.chainId, "chainId"),
|
|
3023
|
+
nonce: parseBigint(fields.nonce, "nonce"),
|
|
3024
|
+
maxPriorityFeePerGas: parseBigint(fields.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
3025
|
+
maxFeePerGas: parseBigint(fields.maxFeePerGas, "maxFeePerGas"),
|
|
3026
|
+
gasLimit: parseBigint(fields.gasLimit, "gasLimit"),
|
|
3027
|
+
to: normalizeTo(fields.to),
|
|
3028
|
+
value: parseBigint(fields.value, "value"),
|
|
3029
|
+
input: normalizeBytes(fields.input ?? new Uint8Array(0), "input"),
|
|
3030
|
+
extensions: normalizeExtensions(fields.extensions)
|
|
3031
|
+
};
|
|
3032
|
+
}
|
|
3033
|
+
function normalizeTo(value) {
|
|
3034
|
+
if (value === null) return null;
|
|
3035
|
+
const bytes = normalizeBytes(value, "to");
|
|
3036
|
+
return expectBytes(bytes, 20, "to");
|
|
3037
|
+
}
|
|
3038
|
+
function normalizeBytes(value, label) {
|
|
3039
|
+
if (typeof value === "string") return hexToBytes2(value, label);
|
|
3040
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
3041
|
+
}
|
|
3042
|
+
function normalizeExtensions(value) {
|
|
3043
|
+
if (value === void 0) return [];
|
|
3044
|
+
return value.map((ext, index) => {
|
|
3045
|
+
if (!Number.isInteger(ext.kind) || ext.kind < 0 || ext.kind > 255) {
|
|
3046
|
+
throw new Error(`extensions[${index}].kind out of u8 range`);
|
|
3047
|
+
}
|
|
3048
|
+
const body = normalizeBytes("bodyHex" in ext ? ext.bodyHex : ext.body, `extensions[${index}].body`);
|
|
3049
|
+
if (body.length > 4294967295) {
|
|
3050
|
+
throw new Error(`extensions[${index}].body exceeds u32 length`);
|
|
3051
|
+
}
|
|
3052
|
+
return { kind: ext.kind, body };
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
function encodeExtensionsForHash(extensions) {
|
|
3056
|
+
const chunks = [bigintToBeBytes(BigInt(extensions.length), 4, "extensions.length")];
|
|
3057
|
+
for (const ext of extensions) {
|
|
3058
|
+
chunks.push(
|
|
3059
|
+
Uint8Array.of(ext.kind),
|
|
3060
|
+
bigintToBeBytes(BigInt(ext.body.length), 4, "extension.body.length"),
|
|
3061
|
+
ext.body
|
|
3062
|
+
);
|
|
3063
|
+
}
|
|
3064
|
+
return concatBytes2(...chunks);
|
|
3065
|
+
}
|
|
3066
|
+
function uint256Be(value, label) {
|
|
3067
|
+
if (value < 0n || value >= 1n << 256n) throw new Error(`${label} out of u256 range`);
|
|
3068
|
+
const out = new Uint8Array(32);
|
|
3069
|
+
let v = value;
|
|
3070
|
+
for (let i = 31; i >= 0; i--) {
|
|
3071
|
+
out[i] = Number(v & 0xffn);
|
|
3072
|
+
v >>= 8n;
|
|
3073
|
+
}
|
|
3074
|
+
return out;
|
|
3075
|
+
}
|
|
3076
|
+
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
3077
|
+
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
3078
|
+
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
3079
|
+
w.bytes(raw);
|
|
3080
|
+
}
|
|
3081
|
+
function bincodeTypedExtensionInto(w, ext) {
|
|
3082
|
+
w.u8(ext.kind);
|
|
3083
|
+
w.bytes(ext.body);
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
// src/crypto/ml-dsa.ts
|
|
3087
|
+
var ML_DSA_65_SEED_LEN = 32;
|
|
3088
|
+
var ML_DSA_65_SIGNING_KEY_LEN = 4032;
|
|
3089
|
+
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
3090
|
+
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
3091
|
+
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
3092
|
+
var ENUM_VARIANT_INDEX_ML_DSA_65 = 3;
|
|
3093
|
+
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
3094
|
+
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
3095
|
+
var MlDsa65Backend = class _MlDsa65Backend {
|
|
3096
|
+
#secretKey;
|
|
3097
|
+
#publicKey;
|
|
3098
|
+
#addressBytes;
|
|
3099
|
+
#disposed = false;
|
|
3100
|
+
constructor(secretKey, publicKey) {
|
|
3101
|
+
this.#secretKey = expectBytes(secretKey, ML_DSA_65_SIGNING_KEY_LEN, "ML-DSA-65 secret key").slice();
|
|
3102
|
+
this.#publicKey = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key").slice();
|
|
3103
|
+
this.#addressBytes = mlDsa65AddressBytes(this.#publicKey);
|
|
3104
|
+
}
|
|
3105
|
+
static fromSeed(seed) {
|
|
3106
|
+
const kp = mlDsa_js.ml_dsa65.keygen(expectBytes(seed, ML_DSA_65_SEED_LEN, "ML-DSA-65 seed"));
|
|
3107
|
+
return new _MlDsa65Backend(kp.secretKey, kp.publicKey);
|
|
3108
|
+
}
|
|
3109
|
+
publicKey() {
|
|
3110
|
+
return this.#publicKey.slice();
|
|
3111
|
+
}
|
|
3112
|
+
addressBytes() {
|
|
3113
|
+
return this.#addressBytes.slice();
|
|
3114
|
+
}
|
|
3115
|
+
getAddress() {
|
|
3116
|
+
return bytesToHex2(this.#addressBytes);
|
|
3117
|
+
}
|
|
3118
|
+
sign(message) {
|
|
3119
|
+
if (this.#disposed) {
|
|
3120
|
+
throw new Error("MlDsa65Backend disposed");
|
|
3121
|
+
}
|
|
3122
|
+
return mlDsa_js.ml_dsa65.sign(message, this.#secretKey, { extraEntropy: false });
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Best-effort deterministic wipe of the in-memory secret key. Zeroes the
|
|
3126
|
+
* SDK-held `#secretKey` copy and makes any subsequent `sign()` /
|
|
3127
|
+
* `signPrehash()` / `signEvmTx()` throw `"MlDsa65Backend disposed"` rather
|
|
3128
|
+
* than signing with a zeroed key. Idempotent. Public material
|
|
3129
|
+
* (`publicKey()` / `getAddress()` / `verify()`) stays usable.
|
|
3130
|
+
*
|
|
3131
|
+
* Defense-in-depth (S1-01): narrows the post-lock residency window of the
|
|
3132
|
+
* ML-DSA-65 secret in the JS heap. `@noble/post-quantum`'s internal
|
|
3133
|
+
* transient keygen/sign buffers are out of scope; the SDK-held copy is the
|
|
3134
|
+
* meaningful residency win.
|
|
3135
|
+
*/
|
|
3136
|
+
dispose() {
|
|
3137
|
+
this.#secretKey.fill(0);
|
|
3138
|
+
this.#disposed = true;
|
|
3139
|
+
}
|
|
3140
|
+
/** Alias for {@link dispose}. */
|
|
3141
|
+
zeroize() {
|
|
3142
|
+
this.dispose();
|
|
3362
3143
|
}
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3144
|
+
/** Whether {@link dispose} has been called (the secret key is wiped). */
|
|
3145
|
+
get disposed() {
|
|
3146
|
+
return this.#disposed;
|
|
3366
3147
|
}
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
function validateHexLength(field2, value, expected) {
|
|
3370
|
-
const bytes = hexToBytes3(value, field2);
|
|
3371
|
-
if (bytes.length !== expected) throw new MrvValidationError(`${field2} must be ${expected} bytes`);
|
|
3372
|
-
}
|
|
3373
|
-
function bytesFrom(value, field2) {
|
|
3374
|
-
if (typeof value === "string") return hexToBytes3(value, field2);
|
|
3375
|
-
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
3376
|
-
}
|
|
3377
|
-
function hexToBytes3(value, field2) {
|
|
3378
|
-
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
3379
|
-
throw new MrvValidationError(`${field2} must be 0x-prefixed even-length hex`);
|
|
3148
|
+
signPrehash(digest) {
|
|
3149
|
+
return this.sign(expectBytes(digest, 32, "prehash"));
|
|
3380
3150
|
}
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3151
|
+
verify(message, signature) {
|
|
3152
|
+
return mlDsa_js.ml_dsa65.verify(
|
|
3153
|
+
expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature"),
|
|
3154
|
+
message,
|
|
3155
|
+
this.#publicKey
|
|
3156
|
+
);
|
|
3384
3157
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3158
|
+
signEvmTx(fields) {
|
|
3159
|
+
const txHashPreimage = encodeTransactionForHash(fields, 1);
|
|
3160
|
+
const sighash = sha3_js.keccak_256(txHashPreimage);
|
|
3161
|
+
const signature = this.sign(sighash);
|
|
3162
|
+
const wireBytes = bincodeSignedTransaction(fields, signature, this.#publicKey);
|
|
3163
|
+
const txHash = sha3_js.keccak_256(
|
|
3164
|
+
concatBytes2(
|
|
3165
|
+
encodeTransactionForHash(fields, 2),
|
|
3166
|
+
signature,
|
|
3167
|
+
this.#publicKey
|
|
3168
|
+
)
|
|
3169
|
+
);
|
|
3170
|
+
return {
|
|
3171
|
+
wireHex: bytesToHex2(wireBytes).slice(2),
|
|
3172
|
+
wireBytes,
|
|
3173
|
+
sighash,
|
|
3174
|
+
txHash
|
|
3175
|
+
};
|
|
3397
3176
|
}
|
|
3398
|
-
|
|
3177
|
+
};
|
|
3178
|
+
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
3179
|
+
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
3399
3180
|
}
|
|
3400
|
-
function
|
|
3401
|
-
|
|
3181
|
+
function mlDsa65AddressBytes(publicKey) {
|
|
3182
|
+
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
3183
|
+
return blake3_js.blake3(concatBytes2(
|
|
3184
|
+
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
3185
|
+
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
3186
|
+
bytes
|
|
3187
|
+
)).slice(0, 20);
|
|
3402
3188
|
}
|
|
3403
3189
|
|
|
3404
3190
|
// src/registry.ts
|
|
@@ -3408,8 +3194,8 @@ var TESTNET_69420 = {
|
|
|
3408
3194
|
network: "testnet-69420",
|
|
3409
3195
|
display_name: "Monolythium Testnet",
|
|
3410
3196
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
3411
|
-
genesis_hash: "
|
|
3412
|
-
binary_sha: "
|
|
3197
|
+
genesis_hash: "0xb52b59d667a0ad97c531607b840b7082547ba3151aa11a819eb6916b080b1ca9",
|
|
3198
|
+
binary_sha: "6f33aa30",
|
|
3413
3199
|
rpc: [
|
|
3414
3200
|
{
|
|
3415
3201
|
url: "http://178.105.12.9:8545",
|
|
@@ -4989,14 +4775,6 @@ var RpcClient = class _RpcClient {
|
|
|
4989
4775
|
async lythSubmitPendingChange(envelope) {
|
|
4990
4776
|
return this.call("lyth_submitPendingChange", [envelope]);
|
|
4991
4777
|
}
|
|
4992
|
-
/** `lyth_submitEncrypted` — submit a bincode-encoded encrypted envelope hex. */
|
|
4993
|
-
async lythSubmitEncrypted(envelopeHex) {
|
|
4994
|
-
return this.call("lyth_submitEncrypted", [envelopeHex]);
|
|
4995
|
-
}
|
|
4996
|
-
/** `lyth_getEncryptionKey` — cluster ML-KEM encapsulation key. */
|
|
4997
|
-
async lythGetEncryptionKey() {
|
|
4998
|
-
return this.call("lyth_getEncryptionKey", []);
|
|
4999
|
-
}
|
|
5000
4778
|
/** `lyth_syncStatus` — DAG-sync driver snapshot. */
|
|
5001
4779
|
async lythSyncStatus() {
|
|
5002
4780
|
const v = await this.call("lyth_syncStatus", []);
|
|
@@ -8153,7 +7931,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
8153
7931
|
}
|
|
8154
7932
|
const actualRoot = computeNoEvmReceiptsRoot(receipts);
|
|
8155
7933
|
const expectedRoot = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
8156
|
-
if (!
|
|
7934
|
+
if (!bytesEqual2(expectedRoot, decodeHash(actualRoot, "computedReceiptsRoot"))) {
|
|
8157
7935
|
throw new NoEvmReceiptProofError(
|
|
8158
7936
|
"receipts_root_mismatch",
|
|
8159
7937
|
`receiptsRoot mismatch: expected ${proof.receiptsRoot}, computed ${actualRoot}`
|
|
@@ -8161,7 +7939,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
8161
7939
|
}
|
|
8162
7940
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
8163
7941
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
8164
|
-
if (!
|
|
7942
|
+
if (!bytesEqual2(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
8165
7943
|
throw new NoEvmReceiptProofError(
|
|
8166
7944
|
"target_receipt_hash_mismatch",
|
|
8167
7945
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -8218,7 +7996,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8218
7996
|
const targetReceipt = decodeHexBytes(targetReceiptBytes, "targetReceiptBytes");
|
|
8219
7997
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
8220
7998
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
8221
|
-
if (!
|
|
7999
|
+
if (!bytesEqual2(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
8222
8000
|
throw new NoEvmReceiptProofError(
|
|
8223
8001
|
"target_receipt_hash_mismatch",
|
|
8224
8002
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -8229,7 +8007,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8229
8007
|
compactProof.leafHash,
|
|
8230
8008
|
"compactInclusionProof.leafHash"
|
|
8231
8009
|
);
|
|
8232
|
-
if (!
|
|
8010
|
+
if (!bytesEqual2(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
8233
8011
|
throw new NoEvmReceiptProofError(
|
|
8234
8012
|
"compact_leaf_hash_mismatch",
|
|
8235
8013
|
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
@@ -8239,7 +8017,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8239
8017
|
}
|
|
8240
8018
|
const compactRootBytes = decodeHash(compactProof.root, "compactInclusionProof.root");
|
|
8241
8019
|
const receiptsRootBytes = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
8242
|
-
if (!
|
|
8020
|
+
if (!bytesEqual2(receiptsRootBytes, compactRootBytes)) {
|
|
8243
8021
|
throw new NoEvmReceiptProofError(
|
|
8244
8022
|
"compact_root_mismatch",
|
|
8245
8023
|
`receiptsRoot must equal compactInclusionProof.root: receiptsRoot ${proof.receiptsRoot}, compact root ${compactProof.root}`
|
|
@@ -8262,7 +8040,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8262
8040
|
siblingHashes,
|
|
8263
8041
|
pathSides
|
|
8264
8042
|
);
|
|
8265
|
-
if (!
|
|
8043
|
+
if (!bytesEqual2(actualRootBytes, compactRootBytes)) {
|
|
8266
8044
|
throw new NoEvmReceiptProofError(
|
|
8267
8045
|
"compact_path_mismatch",
|
|
8268
8046
|
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
@@ -8416,7 +8194,7 @@ function validateCoveringSnapshotObject(snapshot, archiveContentHash, proofBlock
|
|
|
8416
8194
|
"archiveProof.coveringSnapshot.checkpointTo must match blockHeight"
|
|
8417
8195
|
);
|
|
8418
8196
|
}
|
|
8419
|
-
if (!
|
|
8197
|
+
if (!bytesEqual2(checkpointContentHash, archiveContentHash)) {
|
|
8420
8198
|
throw new NoEvmReceiptProofError(
|
|
8421
8199
|
"invalid_proof_shape",
|
|
8422
8200
|
"archiveProof.coveringSnapshot.checkpointContentHash must match archiveProof.contentHash"
|
|
@@ -8615,7 +8393,7 @@ function validateFinalityBlockReference(blockReference, round, proofBlockHash) {
|
|
|
8615
8393
|
);
|
|
8616
8394
|
if (proofBlockHash !== void 0) {
|
|
8617
8395
|
const blockHash = decodeHash(proofBlockHash, "blockHash");
|
|
8618
|
-
if (!
|
|
8396
|
+
if (!bytesEqual2(digest, blockHash)) {
|
|
8619
8397
|
throw new NoEvmReceiptProofError(
|
|
8620
8398
|
"invalid_proof_shape",
|
|
8621
8399
|
"finalityEvidence.blockReference.digest must match blockHash"
|
|
@@ -8965,7 +8743,7 @@ function assertHashBytes(value, field2) {
|
|
|
8965
8743
|
function isRecord3(value) {
|
|
8966
8744
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8967
8745
|
}
|
|
8968
|
-
function
|
|
8746
|
+
function bytesEqual2(a, b) {
|
|
8969
8747
|
if (a.length !== b.length) return false;
|
|
8970
8748
|
let diff = 0;
|
|
8971
8749
|
for (let index = 0; index < a.length; index++) {
|
|
@@ -8980,6 +8758,191 @@ function bytesToHex6(bytes) {
|
|
|
8980
8758
|
}
|
|
8981
8759
|
return out;
|
|
8982
8760
|
}
|
|
8761
|
+
var TREE_TAG_LEAF = 0;
|
|
8762
|
+
var TREE_TAG_INTERNAL = 1;
|
|
8763
|
+
var TREE_TERMINATOR = new Uint8Array(32);
|
|
8764
|
+
var HASH_BYTE_LENGTH2 = 32;
|
|
8765
|
+
var PROOF_KIND_BINARY = "binary";
|
|
8766
|
+
var ProofVerifyError = class extends Error {
|
|
8767
|
+
constructor(code, message) {
|
|
8768
|
+
super(message);
|
|
8769
|
+
this.code = code;
|
|
8770
|
+
this.name = "ProofVerifyError";
|
|
8771
|
+
}
|
|
8772
|
+
code;
|
|
8773
|
+
};
|
|
8774
|
+
function hashValue(data) {
|
|
8775
|
+
return blake3_js.blake3(data);
|
|
8776
|
+
}
|
|
8777
|
+
function hashLeaf(path, valueHash) {
|
|
8778
|
+
const buf = new Uint8Array(1 + 32 + 32);
|
|
8779
|
+
buf[0] = TREE_TAG_LEAF;
|
|
8780
|
+
buf.set(path, 1);
|
|
8781
|
+
buf.set(valueHash, 33);
|
|
8782
|
+
return blake3_js.blake3(buf);
|
|
8783
|
+
}
|
|
8784
|
+
function compress(left, right) {
|
|
8785
|
+
if (isTerminator(left) && isTerminator(right)) {
|
|
8786
|
+
return TREE_TERMINATOR;
|
|
8787
|
+
}
|
|
8788
|
+
const buf = new Uint8Array(1 + 32 + 32);
|
|
8789
|
+
buf[0] = TREE_TAG_INTERNAL;
|
|
8790
|
+
buf.set(left, 1);
|
|
8791
|
+
buf.set(right, 33);
|
|
8792
|
+
return blake3_js.blake3(buf);
|
|
8793
|
+
}
|
|
8794
|
+
function isTerminator(hash) {
|
|
8795
|
+
for (let i = 0; i < hash.length; i++) {
|
|
8796
|
+
if (hash[i] !== 0) return false;
|
|
8797
|
+
}
|
|
8798
|
+
return true;
|
|
8799
|
+
}
|
|
8800
|
+
function pathBit(path, depth) {
|
|
8801
|
+
const byte = path[depth >>> 3];
|
|
8802
|
+
return byte >>> 7 - (depth & 7) & 1;
|
|
8803
|
+
}
|
|
8804
|
+
function foldToRoot(target, current, siblings) {
|
|
8805
|
+
const depth = siblings.length;
|
|
8806
|
+
let node = current;
|
|
8807
|
+
for (let i = 0; i < depth; i++) {
|
|
8808
|
+
const level = depth - 1 - i;
|
|
8809
|
+
const sibling = siblings[i];
|
|
8810
|
+
node = pathBit(target, level) === 0 ? compress(node, sibling) : compress(sibling, node);
|
|
8811
|
+
}
|
|
8812
|
+
return node;
|
|
8813
|
+
}
|
|
8814
|
+
function bytesEqual3(a, b) {
|
|
8815
|
+
if (a.length !== b.length) return false;
|
|
8816
|
+
for (let i = 0; i < a.length; i++) {
|
|
8817
|
+
if (a[i] !== b[i]) return false;
|
|
8818
|
+
}
|
|
8819
|
+
return true;
|
|
8820
|
+
}
|
|
8821
|
+
function decodeHash2(value, field2) {
|
|
8822
|
+
let bytes;
|
|
8823
|
+
try {
|
|
8824
|
+
bytes = hexToBytes2(value, field2);
|
|
8825
|
+
} catch (cause) {
|
|
8826
|
+
throw new ProofVerifyError("invalid_hex", `${field2} is not valid hex: ${String(cause)}`);
|
|
8827
|
+
}
|
|
8828
|
+
if (bytes.length !== HASH_BYTE_LENGTH2) {
|
|
8829
|
+
throw new ProofVerifyError(
|
|
8830
|
+
"invalid_hash_length",
|
|
8831
|
+
`${field2} must be ${HASH_BYTE_LENGTH2} bytes, got ${bytes.length}`
|
|
8832
|
+
);
|
|
8833
|
+
}
|
|
8834
|
+
return bytes;
|
|
8835
|
+
}
|
|
8836
|
+
function decodeSiblings(siblings) {
|
|
8837
|
+
return siblings.map((sib, index) => decodeHash2(sib, `siblings[${index}]`));
|
|
8838
|
+
}
|
|
8839
|
+
function assertBinaryKind(proofKind) {
|
|
8840
|
+
if (proofKind !== PROOF_KIND_BINARY) {
|
|
8841
|
+
throw new ProofVerifyError(
|
|
8842
|
+
"unsupported_proof_kind",
|
|
8843
|
+
`unsupported proofKind: ${proofKind} (expected ${PROOF_KIND_BINARY})`
|
|
8844
|
+
);
|
|
8845
|
+
}
|
|
8846
|
+
}
|
|
8847
|
+
var ProofVerifier = class {
|
|
8848
|
+
/**
|
|
8849
|
+
* Verify a {@link ProofEnvelope} inclusion proof against `stateRoot`.
|
|
8850
|
+
*
|
|
8851
|
+
* @returns `true` when the proof binds `(key, value)` to `stateRoot`.
|
|
8852
|
+
*/
|
|
8853
|
+
verifyInclusion(stateRoot, proof) {
|
|
8854
|
+
assertBinaryKind(proof.proofKind);
|
|
8855
|
+
const root = toHashBytes(stateRoot, "stateRoot");
|
|
8856
|
+
const key = decodeHex(proof.key, "proof.key");
|
|
8857
|
+
const value = decodeHex(proof.value, "proof.value");
|
|
8858
|
+
const siblings = decodeSiblings(proof.siblings);
|
|
8859
|
+
const target = hashValue(key);
|
|
8860
|
+
const leaf = hashLeaf(target, hashValue(value));
|
|
8861
|
+
return bytesEqual3(foldToRoot(target, leaf, siblings), root);
|
|
8862
|
+
}
|
|
8863
|
+
/**
|
|
8864
|
+
* Verify a {@link ProofEnvelope} inclusion proof, throwing a
|
|
8865
|
+
* {@link ProofVerifyError} on failure (the loud variant for wallets).
|
|
8866
|
+
*/
|
|
8867
|
+
assertInclusion(stateRoot, proof) {
|
|
8868
|
+
if (!this.verifyInclusion(stateRoot, proof)) {
|
|
8869
|
+
throw new ProofVerifyError(
|
|
8870
|
+
"proof_verify_failed",
|
|
8871
|
+
`inclusion proof for key ${proof.key} does not verify against the state root`
|
|
8872
|
+
);
|
|
8873
|
+
}
|
|
8874
|
+
}
|
|
8875
|
+
/**
|
|
8876
|
+
* Verify a {@link NonInclusionProofEnvelope} against `stateRoot`.
|
|
8877
|
+
*
|
|
8878
|
+
* Returns `false` for a `found` endpoint (that is an inclusion, not
|
|
8879
|
+
* absence) or an `otherLeaf` whose path equals the queried key. Mirrors
|
|
8880
|
+
* `protocore_state::verify_binary_non_inclusion`.
|
|
8881
|
+
*/
|
|
8882
|
+
verifyNonInclusion(stateRoot, proof) {
|
|
8883
|
+
assertBinaryKind(proof.proofKind);
|
|
8884
|
+
const root = toHashBytes(stateRoot, "stateRoot");
|
|
8885
|
+
const key = decodeHex(proof.key, "proof.key");
|
|
8886
|
+
const siblings = decodeSiblings(proof.siblings);
|
|
8887
|
+
const target = hashValue(key);
|
|
8888
|
+
let endpointHash;
|
|
8889
|
+
switch (proof.endpoint.kind) {
|
|
8890
|
+
case "found":
|
|
8891
|
+
return false;
|
|
8892
|
+
case "terminator":
|
|
8893
|
+
endpointHash = TREE_TERMINATOR;
|
|
8894
|
+
break;
|
|
8895
|
+
case "otherLeaf": {
|
|
8896
|
+
const path = decodeHash2(proof.endpoint.path, "endpoint.path");
|
|
8897
|
+
if (bytesEqual3(path, target)) return false;
|
|
8898
|
+
endpointHash = hashLeaf(path, decodeHash2(proof.endpoint.valueHash, "endpoint.valueHash"));
|
|
8899
|
+
break;
|
|
8900
|
+
}
|
|
8901
|
+
}
|
|
8902
|
+
return bytesEqual3(foldToRoot(target, endpointHash, siblings), root);
|
|
8903
|
+
}
|
|
8904
|
+
/**
|
|
8905
|
+
* Verify a non-inclusion proof, throwing a {@link ProofVerifyError} on
|
|
8906
|
+
* failure.
|
|
8907
|
+
*/
|
|
8908
|
+
assertNonInclusion(stateRoot, proof) {
|
|
8909
|
+
if (!this.verifyNonInclusion(stateRoot, proof)) {
|
|
8910
|
+
throw new ProofVerifyError(
|
|
8911
|
+
"non_inclusion_verify_failed",
|
|
8912
|
+
`non-inclusion proof for key ${proof.key} does not verify against the state root`
|
|
8913
|
+
);
|
|
8914
|
+
}
|
|
8915
|
+
}
|
|
8916
|
+
};
|
|
8917
|
+
var proofVerifier = new ProofVerifier();
|
|
8918
|
+
function toHashBytes(value, field2) {
|
|
8919
|
+
if (typeof value === "string") return decodeHash2(value, field2);
|
|
8920
|
+
return expectBytes(value, HASH_BYTE_LENGTH2, field2);
|
|
8921
|
+
}
|
|
8922
|
+
function decodeHex(value, field2) {
|
|
8923
|
+
try {
|
|
8924
|
+
return hexToBytes2(value, field2);
|
|
8925
|
+
} catch (cause) {
|
|
8926
|
+
throw new ProofVerifyError("invalid_hex", `${field2} is not valid hex: ${String(cause)}`);
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
function asBinaryProofEnvelope(proof) {
|
|
8930
|
+
if (proof == null || typeof proof !== "object") return null;
|
|
8931
|
+
const obj = proof;
|
|
8932
|
+
if (obj.proofKind !== PROOF_KIND_BINARY) return null;
|
|
8933
|
+
if (typeof obj.key !== "string" || typeof obj.value !== "string" || !Array.isArray(obj.siblings) || obj.siblings.some((s) => typeof s !== "string")) {
|
|
8934
|
+
return null;
|
|
8935
|
+
}
|
|
8936
|
+
return {
|
|
8937
|
+
proofKind: PROOF_KIND_BINARY,
|
|
8938
|
+
siblings: obj.siblings,
|
|
8939
|
+
key: obj.key,
|
|
8940
|
+
value: obj.value
|
|
8941
|
+
};
|
|
8942
|
+
}
|
|
8943
|
+
function hashToHex(hash) {
|
|
8944
|
+
return bytesToHex2(hash);
|
|
8945
|
+
}
|
|
8983
8946
|
|
|
8984
8947
|
// src/native-dev.ts
|
|
8985
8948
|
var NATIVE_DEV_HOST_API_VERSION = "0.1.0";
|
|
@@ -9173,72 +9136,47 @@ function assertWholeNumber(field2, value) {
|
|
|
9173
9136
|
throw new Error(`${field2} must be a whole number`);
|
|
9174
9137
|
}
|
|
9175
9138
|
}
|
|
9176
|
-
var
|
|
9177
|
-
var
|
|
9178
|
-
var
|
|
9179
|
-
var
|
|
9180
|
-
var PQM1_V1_MLDSA65_DOMAIN_TAG = "monolythium.pqm1.v1.mldsa65";
|
|
9181
|
-
var Pqm1Error = class extends Error {
|
|
9139
|
+
var MLDSA65_MNEMONIC_WORDS = 24;
|
|
9140
|
+
var MLDSA65_SEED_DOMAIN = "monolythium.mldsa65.v1";
|
|
9141
|
+
var DOMAIN_BYTES = new TextEncoder().encode(MLDSA65_SEED_DOMAIN);
|
|
9142
|
+
var MnemonicError = class extends Error {
|
|
9182
9143
|
constructor(kind, message) {
|
|
9183
9144
|
super(message);
|
|
9184
9145
|
this.kind = kind;
|
|
9185
|
-
this.name = "
|
|
9146
|
+
this.name = "MnemonicError";
|
|
9186
9147
|
}
|
|
9187
9148
|
kind;
|
|
9188
9149
|
};
|
|
9189
|
-
var DOMAIN_BYTES = new TextEncoder().encode(PQM1_V1_MLDSA65_DOMAIN_TAG);
|
|
9190
9150
|
function normalizeMnemonic(mnemonic) {
|
|
9191
9151
|
return mnemonic.trim().toLowerCase().replace(/\s+/g, " ");
|
|
9192
9152
|
}
|
|
9193
|
-
function
|
|
9194
|
-
|
|
9195
|
-
throw new Pqm1Error("badPayloadLength", `PQM-1 payload must be ${PQM1_PAYLOAD_LEN} bytes, got ${bytes.length}`);
|
|
9196
|
-
}
|
|
9197
|
-
if (bytes[0] !== PQM1_ALGO_TAG_MLDSA65) {
|
|
9198
|
-
throw new Pqm1Error("unsupportedAlgorithm", `unsupported PQM-1 algorithm tag 0x${bytes[0].toString(16).padStart(2, "0")}`);
|
|
9199
|
-
}
|
|
9200
|
-
if (bytes[1] !== PQM1_VERSION_V1) {
|
|
9201
|
-
throw new Pqm1Error("unsupportedVersion", `unsupported PQM-1 version 0x${bytes[1].toString(16).padStart(2, "0")}`);
|
|
9202
|
-
}
|
|
9203
|
-
}
|
|
9204
|
-
function parsePqm1Payload(payload) {
|
|
9205
|
-
const bytes = expectBytes(payload, PQM1_PAYLOAD_LEN, "PQM-1 payload").slice();
|
|
9206
|
-
ensureSupportedPayload(bytes);
|
|
9207
|
-
return {
|
|
9208
|
-
algoTag: PQM1_ALGO_TAG_MLDSA65,
|
|
9209
|
-
version: PQM1_VERSION_V1,
|
|
9210
|
-
entropy: bytes.slice(2),
|
|
9211
|
-
bytes
|
|
9212
|
-
};
|
|
9153
|
+
function wordCount(normalized) {
|
|
9154
|
+
return normalized.length === 0 ? 0 : normalized.split(" ").length;
|
|
9213
9155
|
}
|
|
9214
|
-
function
|
|
9156
|
+
function mnemonicToMlDsa65Seed(mnemonic) {
|
|
9215
9157
|
const normalized = normalizeMnemonic(mnemonic);
|
|
9216
|
-
const words = normalized
|
|
9217
|
-
if (words
|
|
9218
|
-
throw new
|
|
9158
|
+
const words = wordCount(normalized);
|
|
9159
|
+
if (words !== MLDSA65_MNEMONIC_WORDS) {
|
|
9160
|
+
throw new MnemonicError(
|
|
9161
|
+
"badWordCount",
|
|
9162
|
+
`mnemonic must be ${MLDSA65_MNEMONIC_WORDS} words, got ${words}`
|
|
9163
|
+
);
|
|
9219
9164
|
}
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9165
|
+
if (!bip39.validateMnemonic(normalized, english_js.wordlist)) {
|
|
9166
|
+
throw new MnemonicError(
|
|
9167
|
+
"bip39Decode",
|
|
9168
|
+
"invalid BIP-39 mnemonic (unknown word or bad checksum)"
|
|
9169
|
+
);
|
|
9225
9170
|
}
|
|
9226
|
-
|
|
9227
|
-
}
|
|
9228
|
-
function derivePqm1MlDsa65SeedFromPayload(payload) {
|
|
9229
|
-
const parsed = parsePqm1Payload(payload);
|
|
9230
|
-
return sha3_js.shake256(concatBytes2(DOMAIN_BYTES, parsed.bytes), { dkLen: ML_DSA_65_SEED_LEN });
|
|
9171
|
+
const seed64 = bip39.mnemonicToSeedSync(normalized, "");
|
|
9172
|
+
return sha3_js.shake256(concatBytes2(DOMAIN_BYTES, seed64), { dkLen: ML_DSA_65_SEED_LEN });
|
|
9231
9173
|
}
|
|
9232
|
-
function
|
|
9233
|
-
return
|
|
9234
|
-
}
|
|
9235
|
-
function pqm1MnemonicToMlDsa65Backend(mnemonic) {
|
|
9236
|
-
return MlDsa65Backend.fromSeed(pqm1MnemonicToMlDsa65Seed(mnemonic));
|
|
9174
|
+
function mnemonicToMlDsa65Backend(mnemonic) {
|
|
9175
|
+
return MlDsa65Backend.fromSeed(mnemonicToMlDsa65Seed(mnemonic));
|
|
9237
9176
|
}
|
|
9238
9177
|
|
|
9239
9178
|
// src/cluster-join.ts
|
|
9240
9179
|
var DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
9241
|
-
var DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
9242
9180
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
9243
9181
|
var MAX_UINT32 = (1n << 32n) - 1n;
|
|
9244
9182
|
function deriveClusterJoinOperatorId(operatorPubkey) {
|
|
@@ -9346,29 +9284,11 @@ function buildVoteClusterAdmitTxFields(args) {
|
|
|
9346
9284
|
})
|
|
9347
9285
|
};
|
|
9348
9286
|
}
|
|
9349
|
-
function buildPublishOperatorSealKeyTxFields(args) {
|
|
9350
|
-
return {
|
|
9351
|
-
chainId: args.chainId,
|
|
9352
|
-
nonce: args.nonce,
|
|
9353
|
-
maxFeePerGas: parseBigint(args.fee.maxFeePerGas, "maxFeePerGas"),
|
|
9354
|
-
maxPriorityFeePerGas: parseBigint(args.fee.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
9355
|
-
gasLimit: parseBigint(
|
|
9356
|
-
args.fee.gasLimit ?? DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT,
|
|
9357
|
-
"gasLimit"
|
|
9358
|
-
),
|
|
9359
|
-
to: nodeRegistryAddressHex(),
|
|
9360
|
-
value: 0n,
|
|
9361
|
-
input: encodePublishOperatorSealKeyCalldata({
|
|
9362
|
-
peerId: normalizeOperatorId(args.peerId),
|
|
9363
|
-
sealEk: normalizeOperatorSealEk(args.sealEk)
|
|
9364
|
-
})
|
|
9365
|
-
};
|
|
9366
|
-
}
|
|
9367
9287
|
async function submitRequestClusterJoin(args) {
|
|
9368
9288
|
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
9369
9289
|
const operatorPubkey = normalizeConsensusPubkey(args.operatorPubkey, "operatorPubkey");
|
|
9370
9290
|
const operatorIdHex = deriveClusterJoinOperatorId(operatorPubkey);
|
|
9371
|
-
const backend =
|
|
9291
|
+
const backend = mnemonicToMlDsa65Backend(args.mnemonic);
|
|
9372
9292
|
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
9373
9293
|
const preview = await previewRequestClusterJoin(args.client, {
|
|
9374
9294
|
from: senderAddress,
|
|
@@ -9390,12 +9310,12 @@ async function submitRequestClusterJoin(args) {
|
|
|
9390
9310
|
operatorPubkey,
|
|
9391
9311
|
bondLythoshi: args.bondLythoshi
|
|
9392
9312
|
});
|
|
9393
|
-
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex
|
|
9313
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
9394
9314
|
}
|
|
9395
9315
|
async function submitVoteClusterAdmit(args) {
|
|
9396
9316
|
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
9397
9317
|
const operatorIdHex = normalizeOperatorId(args.operatorId);
|
|
9398
|
-
const backend =
|
|
9318
|
+
const backend = mnemonicToMlDsa65Backend(args.mnemonic);
|
|
9399
9319
|
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
9400
9320
|
const preview = await previewVoteClusterAdmit(args.client, {
|
|
9401
9321
|
from: senderAddress,
|
|
@@ -9417,62 +9337,9 @@ async function submitVoteClusterAdmit(args) {
|
|
|
9417
9337
|
operatorId: operatorIdHex,
|
|
9418
9338
|
voterPubkey: args.voterPubkey
|
|
9419
9339
|
});
|
|
9420
|
-
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex
|
|
9421
|
-
}
|
|
9422
|
-
async function submitPublishOperatorSealKey(args) {
|
|
9423
|
-
const operatorIdHex = normalizeOperatorId(args.peerId);
|
|
9424
|
-
const sealEk = normalizeOperatorSealEk(args.sealEk);
|
|
9425
|
-
const backend = pqm1MnemonicToMlDsa65Backend(args.mnemonic);
|
|
9426
|
-
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
9427
|
-
const [chainId, nonce, quote] = await Promise.all([
|
|
9428
|
-
args.client.ethChainId(),
|
|
9429
|
-
args.client.lythGetTransactionCount(senderAddress),
|
|
9430
|
-
args.client.lythExecutionUnitPrice()
|
|
9431
|
-
]);
|
|
9432
|
-
const tx = buildPublishOperatorSealKeyTxFields({
|
|
9433
|
-
chainId,
|
|
9434
|
-
nonce,
|
|
9435
|
-
fee: resolveClusterJoinExecutionFee(quote, {
|
|
9436
|
-
...args,
|
|
9437
|
-
executionUnitLimit: args.executionUnitLimit ?? DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT
|
|
9438
|
-
}),
|
|
9439
|
-
peerId: operatorIdHex,
|
|
9440
|
-
sealEk
|
|
9441
|
-
});
|
|
9442
|
-
const plaintext = buildPlaintextSubmission({ backend, tx });
|
|
9443
|
-
const txHash = await submitPlaintextTransaction(
|
|
9444
|
-
args.client,
|
|
9445
|
-
plaintext.signedTxWireHex,
|
|
9446
|
-
plaintext.innerTxHashHex
|
|
9447
|
-
);
|
|
9448
|
-
return {
|
|
9449
|
-
txHash,
|
|
9450
|
-
operatorIdHex,
|
|
9451
|
-
innerSighashHex: plaintext.innerSighashHex,
|
|
9452
|
-
signedTxWireBytes: plaintext.innerWireBytes
|
|
9453
|
-
};
|
|
9340
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
9454
9341
|
}
|
|
9455
|
-
async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex
|
|
9456
|
-
if (options.private !== false) {
|
|
9457
|
-
const encrypted = await buildEncryptedSubmission({
|
|
9458
|
-
client,
|
|
9459
|
-
backend,
|
|
9460
|
-
tx,
|
|
9461
|
-
clusterId: Number(clusterId),
|
|
9462
|
-
clusterSealKeys: options.clusterSealKeys,
|
|
9463
|
-
clusterSealKeysSource: options.clusterSealKeysSource,
|
|
9464
|
-
class: MempoolClass.ContractCall
|
|
9465
|
-
});
|
|
9466
|
-
assertRpcHash(await submitEncryptedEnvelope(client, encrypted.envelopeWireHex));
|
|
9467
|
-
return {
|
|
9468
|
-
txHash: encrypted.innerTxHashHex,
|
|
9469
|
-
clusterId: clusterId.toString(10),
|
|
9470
|
-
operatorIdHex,
|
|
9471
|
-
innerSighashHex: encrypted.innerSighashHex,
|
|
9472
|
-
signedTxWireBytes: encrypted.innerWireBytes,
|
|
9473
|
-
envelopeWireBytes: hexByteLength(encrypted.envelopeWireHex)
|
|
9474
|
-
};
|
|
9475
|
-
}
|
|
9342
|
+
async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex) {
|
|
9476
9343
|
const plaintext = buildPlaintextSubmission({ backend, tx });
|
|
9477
9344
|
const txHash = await submitPlaintextTransaction(
|
|
9478
9345
|
client,
|
|
@@ -9487,16 +9354,6 @@ async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex
|
|
|
9487
9354
|
signedTxWireBytes: plaintext.innerWireBytes
|
|
9488
9355
|
};
|
|
9489
9356
|
}
|
|
9490
|
-
function hexByteLength(value) {
|
|
9491
|
-
const clean = value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value;
|
|
9492
|
-
return clean.length / 2;
|
|
9493
|
-
}
|
|
9494
|
-
function assertRpcHash(value) {
|
|
9495
|
-
const bytes = hexToBytes2(value, "lyth_submitEncrypted tx hash");
|
|
9496
|
-
if (bytes.length !== 32) {
|
|
9497
|
-
throw new Error(`lyth_submitEncrypted tx hash must be 32 bytes, got ${bytes.length}`);
|
|
9498
|
-
}
|
|
9499
|
-
}
|
|
9500
9357
|
function adaptNativeClusterJoinRequest(request) {
|
|
9501
9358
|
return {
|
|
9502
9359
|
owner: request.owner ?? ZERO_ADDRESS,
|
|
@@ -9539,10 +9396,6 @@ function normalizeOperatorId(value) {
|
|
|
9539
9396
|
const bytes = typeof value === "string" ? hexToBytes2(value, "operatorId") : value;
|
|
9540
9397
|
return bytesToHex2(expectBytes(bytes, 32, "operatorId"));
|
|
9541
9398
|
}
|
|
9542
|
-
function normalizeOperatorSealEk(value) {
|
|
9543
|
-
const bytes = typeof value === "string" ? hexToBytes2(value, "sealEk") : value;
|
|
9544
|
-
return expectBytes(bytes, NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES, "sealEk").slice();
|
|
9545
|
-
}
|
|
9546
9399
|
function parseUint32(value, label) {
|
|
9547
9400
|
const parsed = parseBigint(value, label);
|
|
9548
9401
|
if (parsed < 0n || parsed > MAX_UINT32) {
|
|
@@ -9560,6 +9413,77 @@ function parseU256(value, label) {
|
|
|
9560
9413
|
function errorMessage(cause) {
|
|
9561
9414
|
return cause instanceof Error ? cause.message : String(cause);
|
|
9562
9415
|
}
|
|
9416
|
+
|
|
9417
|
+
// src/cluster-seat.ts
|
|
9418
|
+
var DEFAULT_SEAT_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
9419
|
+
function resolveSeatExecutionFee(quote, options = {}) {
|
|
9420
|
+
const quoted = parseBigint(quote.executionUnitPriceLythoshi, "executionUnitPriceLythoshi");
|
|
9421
|
+
const floor = options.minPriceLythoshi === void 0 ? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI : parseBigint(options.minPriceLythoshi, "minPriceLythoshi");
|
|
9422
|
+
const multiplier = options.safetyMultiplier === void 0 ? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER : parseBigint(options.safetyMultiplier, "safetyMultiplier");
|
|
9423
|
+
if (multiplier <= 0n) throw new Error("safetyMultiplier must be greater than zero");
|
|
9424
|
+
const base = quoted > floor ? quoted : floor;
|
|
9425
|
+
const maxFeePerGas = base * multiplier;
|
|
9426
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
9427
|
+
return {
|
|
9428
|
+
maxFeePerGas,
|
|
9429
|
+
maxPriorityFeePerGas: tip,
|
|
9430
|
+
gasLimit: options.executionUnitLimit ?? DEFAULT_SEAT_EXECUTION_UNIT_LIMIT
|
|
9431
|
+
};
|
|
9432
|
+
}
|
|
9433
|
+
function buildAdvertiseSeatTxFields(args) {
|
|
9434
|
+
return {
|
|
9435
|
+
...seatTxEnvelope(args.chainId, args.nonce, args.fee),
|
|
9436
|
+
value: 0n,
|
|
9437
|
+
input: encodeAdvertiseSeatCalldata(args)
|
|
9438
|
+
};
|
|
9439
|
+
}
|
|
9440
|
+
function buildApplyForSeatTxFields(args) {
|
|
9441
|
+
const escrow = args.escrowLythoshi === void 0 ? NODE_REGISTRY_SEAT_APPLICATION_ESCROW_LYTHOSHI : parseU2562(args.escrowLythoshi, "escrowLythoshi");
|
|
9442
|
+
return {
|
|
9443
|
+
...seatTxEnvelope(args.chainId, args.nonce, args.fee),
|
|
9444
|
+
value: escrow,
|
|
9445
|
+
input: encodeApplyForSeatCalldata(args)
|
|
9446
|
+
};
|
|
9447
|
+
}
|
|
9448
|
+
function buildVoteSeatAdmitTxFields(args) {
|
|
9449
|
+
return {
|
|
9450
|
+
...seatTxEnvelope(args.chainId, args.nonce, args.fee),
|
|
9451
|
+
value: 0n,
|
|
9452
|
+
input: encodeVoteSeatAdmitCalldata(args)
|
|
9453
|
+
};
|
|
9454
|
+
}
|
|
9455
|
+
function buildWithdrawSeatApplicationTxFields(args) {
|
|
9456
|
+
return {
|
|
9457
|
+
...seatTxEnvelope(args.chainId, args.nonce, args.fee),
|
|
9458
|
+
value: 0n,
|
|
9459
|
+
input: encodeWithdrawSeatApplicationCalldata(args)
|
|
9460
|
+
};
|
|
9461
|
+
}
|
|
9462
|
+
function buildCloseSeatTxFields(args) {
|
|
9463
|
+
return {
|
|
9464
|
+
...seatTxEnvelope(args.chainId, args.nonce, args.fee),
|
|
9465
|
+
value: 0n,
|
|
9466
|
+
input: encodeCloseSeatCalldata(args)
|
|
9467
|
+
};
|
|
9468
|
+
}
|
|
9469
|
+
var SEAT_KINDS = ["active", "standby"];
|
|
9470
|
+
function seatTxEnvelope(chainId, nonce, fee) {
|
|
9471
|
+
return {
|
|
9472
|
+
chainId,
|
|
9473
|
+
nonce,
|
|
9474
|
+
maxFeePerGas: parseBigint(fee.maxFeePerGas, "maxFeePerGas"),
|
|
9475
|
+
maxPriorityFeePerGas: parseBigint(fee.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
9476
|
+
gasLimit: parseBigint(fee.gasLimit ?? DEFAULT_SEAT_EXECUTION_UNIT_LIMIT, "gasLimit"),
|
|
9477
|
+
to: nodeRegistryAddressHex()
|
|
9478
|
+
};
|
|
9479
|
+
}
|
|
9480
|
+
function parseU2562(value, label) {
|
|
9481
|
+
const parsed = parseBigint(value, label);
|
|
9482
|
+
if (parsed < 0n || parsed >= 1n << 256n) {
|
|
9483
|
+
throw new Error(`${label} out of 256-bit range`);
|
|
9484
|
+
}
|
|
9485
|
+
return parsed;
|
|
9486
|
+
}
|
|
9563
9487
|
var ORACLE_EVENT_SIGS = {
|
|
9564
9488
|
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
9565
9489
|
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
@@ -11051,6 +10975,12 @@ function wordToBigint(word) {
|
|
|
11051
10975
|
}
|
|
11052
10976
|
return out;
|
|
11053
10977
|
}
|
|
10978
|
+
|
|
10979
|
+
// src/crypto/envelope.ts
|
|
10980
|
+
var MempoolClass = {
|
|
10981
|
+
CLOBOp: 3};
|
|
10982
|
+
|
|
10983
|
+
// src/market-actions.ts
|
|
11054
10984
|
var CLOB_MARKET_ID_DOMAIN_TAG = 193;
|
|
11055
10985
|
var NATIVE_MARKET_MODULE_ADDRESS_BYTES = "0x4d41524b45545f4e41544956455f4d4f445f5631";
|
|
11056
10986
|
var NATIVE_MARKET_MODULE_ADDRESS = addressToTypedBech32(
|
|
@@ -12402,7 +12332,7 @@ exports.CLOB_MARKET_ID_DOMAIN_TAG = CLOB_MARKET_ID_DOMAIN_TAG;
|
|
|
12402
12332
|
exports.CLOB_SELECTORS = CLOB_SELECTORS;
|
|
12403
12333
|
exports.CLUSTER_FORMED_EVENT_SIG = CLUSTER_FORMED_EVENT_SIG;
|
|
12404
12334
|
exports.DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT = DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT;
|
|
12405
|
-
exports.
|
|
12335
|
+
exports.DEFAULT_SEAT_EXECUTION_UNIT_LIMIT = DEFAULT_SEAT_EXECUTION_UNIT_LIMIT;
|
|
12406
12336
|
exports.DELEGATION_REVERT_TAGS = DELEGATION_REVERT_TAGS;
|
|
12407
12337
|
exports.DELEGATION_SELECTORS = DELEGATION_SELECTORS;
|
|
12408
12338
|
exports.DIVERSITY_SCORE_MAX = DIVERSITY_SCORE_MAX;
|
|
@@ -12489,16 +12419,20 @@ exports.NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH = NODE_REGISTRY_MAX_MERKLE_PROOF_DE
|
|
|
12489
12419
|
exports.NODE_REGISTRY_MERKLE_INNER_DOMAIN = NODE_REGISTRY_MERKLE_INNER_DOMAIN;
|
|
12490
12420
|
exports.NODE_REGISTRY_MERKLE_LEAF_DOMAIN = NODE_REGISTRY_MERKLE_LEAF_DOMAIN;
|
|
12491
12421
|
exports.NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT = NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT;
|
|
12422
|
+
exports.NODE_REGISTRY_MIN_SELF_BOND_LYTHOSHI = NODE_REGISTRY_MIN_SELF_BOND_LYTHOSHI;
|
|
12492
12423
|
exports.NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES = NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES;
|
|
12493
12424
|
exports.NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES = NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES;
|
|
12494
|
-
exports.NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES = NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES;
|
|
12495
12425
|
exports.NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID;
|
|
12496
12426
|
exports.NODE_REGISTRY_PUBLIC_SERVICE_MASK = NODE_REGISTRY_PUBLIC_SERVICE_MASK;
|
|
12427
|
+
exports.NODE_REGISTRY_SEAT_APPLICATION_ESCROW_LYTHOSHI = NODE_REGISTRY_SEAT_APPLICATION_ESCROW_LYTHOSHI;
|
|
12428
|
+
exports.NODE_REGISTRY_SEAT_KIND_ACTIVE = NODE_REGISTRY_SEAT_KIND_ACTIVE;
|
|
12429
|
+
exports.NODE_REGISTRY_SEAT_KIND_STANDBY = NODE_REGISTRY_SEAT_KIND_STANDBY;
|
|
12497
12430
|
exports.NODE_REGISTRY_SELECTORS = NODE_REGISTRY_SELECTORS;
|
|
12498
12431
|
exports.NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS = NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS;
|
|
12499
12432
|
exports.NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES = NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES;
|
|
12500
12433
|
exports.NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE = NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE;
|
|
12501
12434
|
exports.NODE_REGISTRY_TAG_CLUSTER_CHARTER = NODE_REGISTRY_TAG_CLUSTER_CHARTER;
|
|
12435
|
+
exports.NODE_REGISTRY_TAG_CLUSTER_SEAT = NODE_REGISTRY_TAG_CLUSTER_SEAT;
|
|
12502
12436
|
exports.NODE_REGISTRY_TAG_SERVICE_SCORE = NODE_REGISTRY_TAG_SERVICE_SCORE;
|
|
12503
12437
|
exports.NODE_REGISTRY_TAG_TREASURY = NODE_REGISTRY_TAG_TREASURY;
|
|
12504
12438
|
exports.NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN = NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN;
|
|
@@ -12524,6 +12458,7 @@ exports.OperatorTrustError = OperatorTrustError;
|
|
|
12524
12458
|
exports.OracleEventError = OracleEventError;
|
|
12525
12459
|
exports.PENDING_CHANGE_KIND_CODES = PENDING_CHANGE_KIND_CODES;
|
|
12526
12460
|
exports.PRECOMPILE_ADDRESSES = PRECOMPILE_ADDRESSES;
|
|
12461
|
+
exports.PROOF_KIND_BINARY = PROOF_KIND_BINARY;
|
|
12527
12462
|
exports.PROTOCOL_MAX_OPERATOR_FEE_BPS = PROTOCOL_MAX_OPERATOR_FEE_BPS;
|
|
12528
12463
|
exports.PROVER_MARKET_ADDRESS = PROVER_MARKET_ADDRESS;
|
|
12529
12464
|
exports.PROVER_MARKET_BID_DOMAIN = PROVER_MARKET_BID_DOMAIN;
|
|
@@ -12535,12 +12470,20 @@ exports.PROVER_SLASH_REASON_BAD_PROOF = PROVER_SLASH_REASON_BAD_PROOF;
|
|
|
12535
12470
|
exports.PROVER_SLASH_REASON_NON_DELIVERY = PROVER_SLASH_REASON_NON_DELIVERY;
|
|
12536
12471
|
exports.PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN = PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN;
|
|
12537
12472
|
exports.PUBKEY_REGISTRY_SELECTORS = PUBKEY_REGISTRY_SELECTORS;
|
|
12473
|
+
exports.ProofVerifier = ProofVerifier;
|
|
12474
|
+
exports.ProofVerifyError = ProofVerifyError;
|
|
12538
12475
|
exports.ProverMarketError = ProverMarketError;
|
|
12539
12476
|
exports.PubkeyRegistryError = PubkeyRegistryError;
|
|
12540
12477
|
exports.QUARANTINED_RPC_CODE = QUARANTINED_RPC_CODE;
|
|
12541
12478
|
exports.REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
12542
12479
|
exports.RESERVED_ADDRESS_HRPS = RESERVED_ADDRESS_HRPS;
|
|
12543
12480
|
exports.RpcClient = RpcClient;
|
|
12481
|
+
exports.SEAT_ADVERTISED_EVENT_SIG = SEAT_ADVERTISED_EVENT_SIG;
|
|
12482
|
+
exports.SEAT_APPLIED_EVENT_SIG = SEAT_APPLIED_EVENT_SIG;
|
|
12483
|
+
exports.SEAT_CLOSED_EVENT_SIG = SEAT_CLOSED_EVENT_SIG;
|
|
12484
|
+
exports.SEAT_FILLED_EVENT_SIG = SEAT_FILLED_EVENT_SIG;
|
|
12485
|
+
exports.SEAT_KINDS = SEAT_KINDS;
|
|
12486
|
+
exports.SEAT_STATUS_CODES = SEAT_STATUS_CODES;
|
|
12544
12487
|
exports.SERVES_GPU_PROVE = SERVES_GPU_PROVE;
|
|
12545
12488
|
exports.SERVICE_PROBE_STATUS = SERVICE_PROBE_STATUS;
|
|
12546
12489
|
exports.SET_POLICY_CLAIM_DOMAIN_TAG = SET_POLICY_CLAIM_DOMAIN_TAG;
|
|
@@ -12575,6 +12518,7 @@ exports.allowRootFor = allowRootFor;
|
|
|
12575
12518
|
exports.apiEndpointFromRpcEndpoint = apiEndpointFromRpcEndpoint;
|
|
12576
12519
|
exports.archiveMerkleInnerHash = archiveMerkleInnerHash;
|
|
12577
12520
|
exports.archiveMerkleLeafHash = archiveMerkleLeafHash;
|
|
12521
|
+
exports.asBinaryProofEnvelope = asBinaryProofEnvelope;
|
|
12578
12522
|
exports.assembleMultisigSigned = assembleMultisigSigned;
|
|
12579
12523
|
exports.assembleMultisigWitness = assembleMultisigWitness;
|
|
12580
12524
|
exports.assertMrvCallNativeSubmissionPlan = assertMrvCallNativeSubmissionPlan;
|
|
@@ -12594,8 +12538,11 @@ exports.bridgeDrainRemaining = bridgeDrainRemaining;
|
|
|
12594
12538
|
exports.bridgeQuoteSubmitReadiness = bridgeQuoteSubmitReadiness;
|
|
12595
12539
|
exports.bridgeRoutesReadiness = bridgeRoutesReadiness;
|
|
12596
12540
|
exports.bridgeTransferCandidates = bridgeTransferCandidates;
|
|
12541
|
+
exports.buildAdvertiseSeatTxFields = buildAdvertiseSeatTxFields;
|
|
12542
|
+
exports.buildApplyForSeatTxFields = buildApplyForSeatTxFields;
|
|
12597
12543
|
exports.buildBridgeRouteCatalogue = buildBridgeRouteCatalogue;
|
|
12598
12544
|
exports.buildCancelSpotOrderPlan = buildCancelSpotOrderPlan;
|
|
12545
|
+
exports.buildCloseSeatTxFields = buildCloseSeatTxFields;
|
|
12599
12546
|
exports.buildMrvCallNativeTxPlan = buildMrvCallNativeTxPlan;
|
|
12600
12547
|
exports.buildMrvCallPlan = buildMrvCallPlan;
|
|
12601
12548
|
exports.buildMrvCallRequest = buildMrvCallRequest;
|
|
@@ -12640,9 +12587,10 @@ exports.buildPlaceLimitOrderViaPlan = buildPlaceLimitOrderViaPlan;
|
|
|
12640
12587
|
exports.buildPlaceSpotLimitOrderPlan = buildPlaceSpotLimitOrderPlan;
|
|
12641
12588
|
exports.buildPlaceSpotMarketOrderExPlan = buildPlaceSpotMarketOrderExPlan;
|
|
12642
12589
|
exports.buildPlaceSpotMarketOrderPlan = buildPlaceSpotMarketOrderPlan;
|
|
12643
|
-
exports.buildPublishOperatorSealKeyTxFields = buildPublishOperatorSealKeyTxFields;
|
|
12644
12590
|
exports.buildRequestClusterJoinTxFields = buildRequestClusterJoinTxFields;
|
|
12645
12591
|
exports.buildVoteClusterAdmitTxFields = buildVoteClusterAdmitTxFields;
|
|
12592
|
+
exports.buildVoteSeatAdmitTxFields = buildVoteSeatAdmitTxFields;
|
|
12593
|
+
exports.buildWithdrawSeatApplicationTxFields = buildWithdrawSeatApplicationTxFields;
|
|
12646
12594
|
exports.categoryRoot = categoryRoot;
|
|
12647
12595
|
exports.checkMrvFeeDisplayConformance = checkMrvFeeDisplayConformance;
|
|
12648
12596
|
exports.checkMrvStructuredFeeConformance = checkMrvStructuredFeeConformance;
|
|
@@ -12673,11 +12621,14 @@ exports.decodeNativeReceiptResponse = decodeNativeReceiptResponse;
|
|
|
12673
12621
|
exports.decodeNoEvmReceiptTranscript = decodeNoEvmReceiptTranscript;
|
|
12674
12622
|
exports.decodeOperatorFeeChargedEvent = decodeOperatorFeeChargedEvent;
|
|
12675
12623
|
exports.decodeOperatorNetworkMetadata = decodeOperatorNetworkMetadata;
|
|
12676
|
-
exports.decodeOperatorSealKey = decodeOperatorSealKey;
|
|
12677
12624
|
exports.decodeOracleEvent = decodeOracleEvent;
|
|
12678
12625
|
exports.decodePendingCharter = decodePendingCharter;
|
|
12679
12626
|
exports.decodeProbeAuthority = decodeProbeAuthority;
|
|
12680
12627
|
exports.decodeScoreServiceProbe = decodeScoreServiceProbe;
|
|
12628
|
+
exports.decodeSeatAdvertisedEvent = decodeSeatAdvertisedEvent;
|
|
12629
|
+
exports.decodeSeatAppliedEvent = decodeSeatAppliedEvent;
|
|
12630
|
+
exports.decodeSeatClosedEvent = decodeSeatClosedEvent;
|
|
12631
|
+
exports.decodeSeatFilledEvent = decodeSeatFilledEvent;
|
|
12681
12632
|
exports.decodeTimeWindow = decodeTimeWindow;
|
|
12682
12633
|
exports.decodeTokenFactoryTokenId = decodeTokenFactoryTokenId;
|
|
12683
12634
|
exports.decodeTxFeedResponse = decodeTxFeedResponse;
|
|
@@ -12694,9 +12645,12 @@ exports.deriveMultisigAddress = deriveMultisigAddress;
|
|
|
12694
12645
|
exports.deriveMultisigAddressBytes = deriveMultisigAddressBytes;
|
|
12695
12646
|
exports.deriveNativeSpotMarketId = deriveNativeSpotMarketId;
|
|
12696
12647
|
exports.deriveNativeSpotOrderId = deriveNativeSpotOrderId;
|
|
12648
|
+
exports.deriveSeatApplicationKey = deriveSeatApplicationKey;
|
|
12697
12649
|
exports.deriveTokenFactoryTokenId = deriveTokenFactoryTokenId;
|
|
12698
12650
|
exports.destinationRoot = destinationRoot;
|
|
12651
|
+
exports.encodeAdvertiseSeatCalldata = encodeAdvertiseSeatCalldata;
|
|
12699
12652
|
exports.encodeAnswerArchiveChallengeCalldata = encodeAnswerArchiveChallengeCalldata;
|
|
12653
|
+
exports.encodeApplyForSeatCalldata = encodeApplyForSeatCalldata;
|
|
12700
12654
|
exports.encodeAttestDkgReshareCalldata = encodeAttestDkgReshareCalldata;
|
|
12701
12655
|
exports.encodeAttestServiceProbeCalldata = encodeAttestServiceProbeCalldata;
|
|
12702
12656
|
exports.encodeBlockSelector = encodeBlockSelector;
|
|
@@ -12707,6 +12661,7 @@ exports.encodeCancelOrderCalldata = encodeCancelOrderCalldata;
|
|
|
12707
12661
|
exports.encodeCancelPendingChangeCalldata = encodeCancelPendingChangeCalldata;
|
|
12708
12662
|
exports.encodeClaimCalldata = encodeClaimCalldata;
|
|
12709
12663
|
exports.encodeClaimPolicyByAddressCalldata = encodeClaimPolicyByAddressCalldata;
|
|
12664
|
+
exports.encodeCloseSeatCalldata = encodeCloseSeatCalldata;
|
|
12710
12665
|
exports.encodeClusterCharter = encodeClusterCharter;
|
|
12711
12666
|
exports.encodeCommitArchiveRootCalldata = encodeCommitArchiveRootCalldata;
|
|
12712
12667
|
exports.encodeCreateFixedSupplyMrc20Calldata = encodeCreateFixedSupplyMrc20Calldata;
|
|
@@ -12720,7 +12675,6 @@ exports.encodeExpireClusterJoinCalldata = encodeExpireClusterJoinCalldata;
|
|
|
12720
12675
|
exports.encodeFormClusterCalldata = encodeFormClusterCalldata;
|
|
12721
12676
|
exports.encodeFormClusterV2Calldata = encodeFormClusterV2Calldata;
|
|
12722
12677
|
exports.encodeGetClusterJoinRequestCalldata = encodeGetClusterJoinRequestCalldata;
|
|
12723
|
-
exports.encodeGetOperatorSealKeyCalldata = encodeGetOperatorSealKeyCalldata;
|
|
12724
12678
|
exports.encodeGetPendingCharterCalldata = encodeGetPendingCharterCalldata;
|
|
12725
12679
|
exports.encodeGetProbeAuthorityCalldata = encodeGetProbeAuthorityCalldata;
|
|
12726
12680
|
exports.encodeHasPubkeyCalldata = encodeHasPubkeyCalldata;
|
|
@@ -12780,7 +12734,6 @@ exports.encodePlaceLimitOrderCalldata = encodePlaceLimitOrderCalldata;
|
|
|
12780
12734
|
exports.encodePlaceLimitOrderViaCalldata = encodePlaceLimitOrderViaCalldata;
|
|
12781
12735
|
exports.encodePlaceMarketOrderCalldata = encodePlaceMarketOrderCalldata;
|
|
12782
12736
|
exports.encodePlaceMarketOrderExCalldata = encodePlaceMarketOrderExCalldata;
|
|
12783
|
-
exports.encodePublishOperatorSealKeyCalldata = encodePublishOperatorSealKeyCalldata;
|
|
12784
12737
|
exports.encodeRecoverOperatorNodeCalldata = encodeRecoverOperatorNodeCalldata;
|
|
12785
12738
|
exports.encodeRedelegateCalldata = encodeRedelegateCalldata;
|
|
12786
12739
|
exports.encodeRegisterPubkeyCalldata = encodeRegisterPubkeyCalldata;
|
|
@@ -12815,7 +12768,9 @@ exports.encodeTokenFactoryTransferOwnershipCalldata = encodeTokenFactoryTransfer
|
|
|
12815
12768
|
exports.encodeUndelegateCalldata = encodeUndelegateCalldata;
|
|
12816
12769
|
exports.encodeUpdateCharterCalldata = encodeUpdateCharterCalldata;
|
|
12817
12770
|
exports.encodeVoteClusterAdmitCalldata = encodeVoteClusterAdmitCalldata;
|
|
12771
|
+
exports.encodeVoteSeatAdmitCalldata = encodeVoteSeatAdmitCalldata;
|
|
12818
12772
|
exports.encodeVrfEvaluateCalldata = encodeVrfEvaluateCalldata;
|
|
12773
|
+
exports.encodeWithdrawSeatApplicationCalldata = encodeWithdrawSeatApplicationCalldata;
|
|
12819
12774
|
exports.exportBridgeRouteCatalogueJson = exportBridgeRouteCatalogueJson;
|
|
12820
12775
|
exports.fetchChainInfoLatest = fetchChainInfoLatest;
|
|
12821
12776
|
exports.fetchChainRegistryLatest = fetchChainRegistryLatest;
|
|
@@ -12831,6 +12786,7 @@ exports.getChainInfo = getChainInfo;
|
|
|
12831
12786
|
exports.getNoEvmReceiptTrustPolicy = getNoEvmReceiptTrustPolicy;
|
|
12832
12787
|
exports.getP2pSeeds = getP2pSeeds;
|
|
12833
12788
|
exports.getRpcEndpoints = getRpcEndpoints;
|
|
12789
|
+
exports.hashToHex = hashToHex;
|
|
12834
12790
|
exports.hexToAddressBytes = hexToAddressBytes;
|
|
12835
12791
|
exports.isBridgeAdminLockedRevert = isBridgeAdminLockedRevert;
|
|
12836
12792
|
exports.isBridgeCooldownZeroRevert = isBridgeCooldownZeroRevert;
|
|
@@ -12871,6 +12827,7 @@ exports.nodeRegistryAddressHex = nodeRegistryAddressHex;
|
|
|
12871
12827
|
exports.normalizeAddressHex = normalizeAddressHex;
|
|
12872
12828
|
exports.normalizeBridgeRouteCatalogue = normalizeBridgeRouteCatalogue;
|
|
12873
12829
|
exports.normalizePendingChangeKind = normalizePendingChangeKind;
|
|
12830
|
+
exports.openSeatFromAdvertised = openSeatFromAdvertised;
|
|
12874
12831
|
exports.oracleAddressHex = oracleAddressHex;
|
|
12875
12832
|
exports.oraclePriceToNumber = oraclePriceToNumber;
|
|
12876
12833
|
exports.packTimeWindow = packTimeWindow;
|
|
@@ -12886,6 +12843,7 @@ exports.parseQuantityBig = parseQuantityBig;
|
|
|
12886
12843
|
exports.preflightClusterJoinRequest = preflightClusterJoinRequest;
|
|
12887
12844
|
exports.previewRequestClusterJoin = previewRequestClusterJoin;
|
|
12888
12845
|
exports.previewVoteClusterAdmit = previewVoteClusterAdmit;
|
|
12846
|
+
exports.proofVerifier = proofVerifier;
|
|
12889
12847
|
exports.protocolNonceForEpoch = protocolNonceForEpoch;
|
|
12890
12848
|
exports.proverMarketStateFromByte = proverMarketStateFromByte;
|
|
12891
12849
|
exports.pubkeyRegistryAddressHex = pubkeyRegistryAddressHex;
|
|
@@ -12899,7 +12857,11 @@ exports.resolveClusterJoinExecutionFee = resolveClusterJoinExecutionFee;
|
|
|
12899
12857
|
exports.resolveExecutionFee = resolveExecutionFee;
|
|
12900
12858
|
exports.resolveMaxExecutionUnitPrice = resolveMaxExecutionUnitPrice;
|
|
12901
12859
|
exports.resolveRegistryExecutionFee = resolveRegistryExecutionFee;
|
|
12860
|
+
exports.resolveSeatExecutionFee = resolveSeatExecutionFee;
|
|
12902
12861
|
exports.resolveStudioHostStatus = resolveStudioHostStatus;
|
|
12862
|
+
exports.seatKindFromByte = seatKindFromByte;
|
|
12863
|
+
exports.seatKindToByte = seatKindToByte;
|
|
12864
|
+
exports.seatStatusFromByte = seatStatusFromByte;
|
|
12903
12865
|
exports.selectBridgeTransferRoute = selectBridgeTransferRoute;
|
|
12904
12866
|
exports.selectTrustedOperator = selectTrustedOperator;
|
|
12905
12867
|
exports.selectTrustedOperatorForNetwork = selectTrustedOperatorForNetwork;
|
|
@@ -12919,7 +12881,6 @@ exports.spendingPolicyAddressHex = spendingPolicyAddressHex;
|
|
|
12919
12881
|
exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
|
|
12920
12882
|
exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
|
|
12921
12883
|
exports.submitMrvDeployPayloadNativeTx = submitMrvDeployPayloadNativeTx;
|
|
12922
|
-
exports.submitPublishOperatorSealKey = submitPublishOperatorSealKey;
|
|
12923
12884
|
exports.submitRequestClusterJoin = submitRequestClusterJoin;
|
|
12924
12885
|
exports.submitSighash = submitSighash;
|
|
12925
12886
|
exports.submitVoteClusterAdmit = submitVoteClusterAdmit;
|