@monolythium/core-sdk 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crypto/index.cjs +138 -77
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +3 -252
- package/dist/crypto/index.d.ts +3 -252
- package/dist/crypto/index.js +138 -77
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +1273 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -6
- package/dist/index.d.ts +113 -6
- package/dist/index.js +1243 -94
- package/dist/index.js.map +1 -1
- package/dist/{submission-CKXlYstD.d.cts → submission-Cc9r1eqX.d.cts} +395 -63
- package/dist/{submission-CKXlYstD.d.ts → submission-Cc9r1eqX.d.ts} +395 -63
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { blake3 } from '@noble/hashes/blake3.js';
|
|
2
|
-
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
2
|
+
import { keccak_256, shake256 } from '@noble/hashes/sha3.js';
|
|
3
|
+
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
|
|
4
|
+
import { chacha20poly1305 } from '@noble/ciphers/chacha.js';
|
|
5
|
+
import '@noble/hashes/utils.js';
|
|
3
6
|
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
|
|
4
7
|
import { bls12_381 } from '@noble/curves/bls12-381.js';
|
|
5
|
-
import '@
|
|
6
|
-
import '@
|
|
7
|
-
import '@noble/hashes/utils.js';
|
|
8
|
+
import { mnemonicToEntropy } from '@scure/bip39';
|
|
9
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
8
10
|
|
|
9
11
|
// src/error.ts
|
|
10
12
|
var SdkError = class _SdkError extends Error {
|
|
@@ -435,13 +437,36 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
435
437
|
/** `getOperatorNetworkMetadata(bytes32)` view (PF-6). */
|
|
436
438
|
getOperatorNetworkMetadata: "0x" + selectorHex("getOperatorNetworkMetadata(bytes32)"),
|
|
437
439
|
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
438
|
-
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
440
|
+
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)"),
|
|
441
|
+
/** `requestClusterJoin(uint32,bytes)` — CJ-1 joining operator posts an admit request. */
|
|
442
|
+
requestClusterJoin: "0x" + selectorHex("requestClusterJoin(uint32,bytes)"),
|
|
443
|
+
/** `voteClusterAdmit(uint32,bytes32,bytes)` — CJ-1 current member admit vote. */
|
|
444
|
+
voteClusterAdmit: "0x" + selectorHex("voteClusterAdmit(uint32,bytes32,bytes)"),
|
|
445
|
+
/** `cancelClusterJoin(uint32,bytes32)` — CJ-1 requester cancellation/refund. */
|
|
446
|
+
cancelClusterJoin: "0x" + selectorHex("cancelClusterJoin(uint32,bytes32)"),
|
|
447
|
+
/** `expireClusterJoin(uint32,bytes32)` — CJ-1 public reaper/refund. */
|
|
448
|
+
expireClusterJoin: "0x" + selectorHex("expireClusterJoin(uint32,bytes32)"),
|
|
449
|
+
/** `getClusterJoinRequest(uint32,bytes32)` — CJ-1 request status view. */
|
|
450
|
+
getClusterJoinRequest: "0x" + selectorHex("getClusterJoinRequest(uint32,bytes32)"),
|
|
451
|
+
/** `formCluster(bytes,bytes,bytes)` — no-foundation cluster formation by roster consent. */
|
|
452
|
+
formCluster: "0x" + selectorHex("formCluster(bytes,bytes,bytes)")
|
|
439
453
|
};
|
|
440
|
-
var
|
|
441
|
-
var
|
|
454
|
+
var NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES = 48;
|
|
455
|
+
var NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
|
|
456
|
+
var NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
|
|
457
|
+
var NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES = 1952;
|
|
458
|
+
var NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES = 3309;
|
|
459
|
+
var NODE_REGISTRY_CONSENSUS_POP_BYTES = 3309;
|
|
460
|
+
var NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES = 96;
|
|
461
|
+
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES;
|
|
442
462
|
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
443
463
|
var NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = 7;
|
|
444
464
|
var NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = (1n << 56n) - 1n;
|
|
465
|
+
var NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT = 7;
|
|
466
|
+
var NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT = 3;
|
|
467
|
+
var NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT = NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT + NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT;
|
|
468
|
+
var NODE_REGISTRY_FORM_CLUSTER_THRESHOLD = 7;
|
|
469
|
+
var NODE_REGISTRY_FORM_CLUSTER_MESSAGE_DOMAIN = "PROTOCORE_NODE_REGISTRY_CLUSTER_FORM_V1\0";
|
|
445
470
|
var PENDING_CHANGE_KIND_CODES = {
|
|
446
471
|
add: 1,
|
|
447
472
|
remove: 2,
|
|
@@ -508,7 +533,7 @@ function encodeSubmitPendingChangeCalldata(args) {
|
|
|
508
533
|
const { kind, kindCode } = normalizePendingChangeKind(args.kind);
|
|
509
534
|
const targetPubkey = expectLength2(
|
|
510
535
|
toBytes(args.targetPubkey),
|
|
511
|
-
|
|
536
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
512
537
|
"targetPubkey"
|
|
513
538
|
);
|
|
514
539
|
const effectiveEpoch = toUint64(args.effectiveEpoch, "effectiveEpoch");
|
|
@@ -522,8 +547,7 @@ function encodeSubmitPendingChangeCalldata(args) {
|
|
|
522
547
|
if (kind !== "rotate" && intentId !== 0n) {
|
|
523
548
|
throw new NodeRegistryError("only rotate pending changes may carry a non-zero intentId");
|
|
524
549
|
}
|
|
525
|
-
const
|
|
526
|
-
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
550
|
+
const targetPubkeyPadded = padToWord(targetPubkey);
|
|
527
551
|
return bytesToHex(
|
|
528
552
|
concatBytes(
|
|
529
553
|
hexToBytes(NODE_REGISTRY_SELECTORS.submitPendingChange),
|
|
@@ -531,55 +555,59 @@ function encodeSubmitPendingChangeCalldata(args) {
|
|
|
531
555
|
uint64Word(4n * 32n, "targetPubkeyOffset"),
|
|
532
556
|
uint64Word(effectiveEpoch, "effectiveEpoch"),
|
|
533
557
|
uint64Word(intentId, "intentId"),
|
|
534
|
-
uint64Word(BigInt(
|
|
535
|
-
|
|
536
|
-
targetTail
|
|
558
|
+
uint64Word(BigInt(targetPubkey.length), "targetPubkeyLength"),
|
|
559
|
+
targetPubkeyPadded
|
|
537
560
|
)
|
|
538
561
|
);
|
|
539
562
|
}
|
|
540
563
|
function encodeCancelPendingChangeCalldata(args) {
|
|
541
564
|
const targetPubkey = expectLength2(
|
|
542
565
|
toBytes(args.targetPubkey),
|
|
543
|
-
|
|
566
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
544
567
|
"targetPubkey"
|
|
545
568
|
);
|
|
546
|
-
const
|
|
547
|
-
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
569
|
+
const targetPubkeyPadded = padToWord(targetPubkey);
|
|
548
570
|
return bytesToHex(
|
|
549
571
|
concatBytes(
|
|
550
572
|
hexToBytes(NODE_REGISTRY_SELECTORS.cancelPendingChange),
|
|
551
573
|
uint64Word(args.epoch, "epoch"),
|
|
552
574
|
uint64Word(2n * 32n, "targetPubkeyOffset"),
|
|
553
|
-
uint64Word(BigInt(
|
|
554
|
-
|
|
555
|
-
targetTail
|
|
575
|
+
uint64Word(BigInt(targetPubkey.length), "targetPubkeyLength"),
|
|
576
|
+
targetPubkeyPadded
|
|
556
577
|
)
|
|
557
578
|
);
|
|
558
579
|
}
|
|
559
|
-
function parseDkgResharePublicKeys(
|
|
560
|
-
const keys = toBytes(
|
|
561
|
-
if (keys.length %
|
|
562
|
-
throw new NodeRegistryError(
|
|
580
|
+
function parseDkgResharePublicKeys(consensusPublicKeys) {
|
|
581
|
+
const keys = toBytes(consensusPublicKeys);
|
|
582
|
+
if (keys.length % NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES !== 0) {
|
|
583
|
+
throw new NodeRegistryError(
|
|
584
|
+
`consensusPublicKeys length must be a multiple of ${NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES} bytes`
|
|
585
|
+
);
|
|
563
586
|
}
|
|
564
|
-
const signerCount = keys.length /
|
|
587
|
+
const signerCount = keys.length / NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES;
|
|
565
588
|
if (signerCount < NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS || signerCount > NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS) {
|
|
566
589
|
throw new NodeRegistryError(
|
|
567
|
-
`
|
|
590
|
+
`consensusPublicKeys must contain ${NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS}..${NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS} signers`
|
|
568
591
|
);
|
|
569
592
|
}
|
|
570
593
|
const out = [];
|
|
571
594
|
const seen = /* @__PURE__ */ new Set();
|
|
572
|
-
for (let offset = 0; offset < keys.length; offset +=
|
|
573
|
-
const key = keys.slice(offset, offset +
|
|
595
|
+
for (let offset = 0; offset < keys.length; offset += NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES) {
|
|
596
|
+
const key = keys.slice(offset, offset + NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES);
|
|
574
597
|
const keyHex = bytesToHex(key);
|
|
575
598
|
if (seen.has(keyHex)) {
|
|
576
|
-
throw new NodeRegistryError("
|
|
599
|
+
throw new NodeRegistryError("consensusPublicKeys contains a duplicate signer pubkey");
|
|
577
600
|
}
|
|
578
601
|
seen.add(keyHex);
|
|
579
602
|
out.push(key);
|
|
580
603
|
}
|
|
581
604
|
return out;
|
|
582
605
|
}
|
|
606
|
+
function dkgReshareConsensusPublicKeys(args) {
|
|
607
|
+
if (args.consensusPublicKeys !== void 0) return args.consensusPublicKeys;
|
|
608
|
+
if (args.blsPublicKeys !== void 0) return args.blsPublicKeys;
|
|
609
|
+
throw new NodeRegistryError("consensusPublicKeys is required");
|
|
610
|
+
}
|
|
583
611
|
function encodeAttestDkgReshareCalldata(args) {
|
|
584
612
|
const intentId = toUint64(args.intentId, "intentId");
|
|
585
613
|
if (intentId === 0n) {
|
|
@@ -588,10 +616,10 @@ function encodeAttestDkgReshareCalldata(args) {
|
|
|
588
616
|
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
589
617
|
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
590
618
|
}
|
|
591
|
-
const publicKeys = concatBytes(...parseDkgResharePublicKeys(args
|
|
619
|
+
const publicKeys = concatBytes(...parseDkgResharePublicKeys(dkgReshareConsensusPublicKeys(args)));
|
|
592
620
|
const thresholdSig = expectLength2(
|
|
593
621
|
toBytes(args.thresholdSig),
|
|
594
|
-
|
|
622
|
+
NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES,
|
|
595
623
|
"thresholdSig"
|
|
596
624
|
);
|
|
597
625
|
const keysPadded = padToWord(publicKeys);
|
|
@@ -602,15 +630,158 @@ function encodeAttestDkgReshareCalldata(args) {
|
|
|
602
630
|
concatBytes(
|
|
603
631
|
hexToBytes(NODE_REGISTRY_SELECTORS.attestDkgReshare),
|
|
604
632
|
uint64Word(intentId, "intentId"),
|
|
605
|
-
uint64Word(offsetKeys, "
|
|
633
|
+
uint64Word(offsetKeys, "consensusPublicKeysOffset"),
|
|
606
634
|
uint64Word(offsetSig, "thresholdSigOffset"),
|
|
607
|
-
uint64Word(BigInt(publicKeys.length), "
|
|
635
|
+
uint64Word(BigInt(publicKeys.length), "consensusPublicKeysLength"),
|
|
608
636
|
keysPadded,
|
|
609
637
|
uint64Word(BigInt(thresholdSig.length), "thresholdSigLength"),
|
|
610
638
|
sigPadded
|
|
611
639
|
)
|
|
612
640
|
);
|
|
613
641
|
}
|
|
642
|
+
function encodeRequestClusterJoinCalldata(args) {
|
|
643
|
+
const operatorPubkey = expectLength2(
|
|
644
|
+
toBytes(args.operatorPubkey),
|
|
645
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
646
|
+
"operatorPubkey"
|
|
647
|
+
);
|
|
648
|
+
const operatorPubkeyPadded = padToWord(operatorPubkey);
|
|
649
|
+
return bytesToHex(
|
|
650
|
+
concatBytes(
|
|
651
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.requestClusterJoin),
|
|
652
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
653
|
+
uint64Word(2n * 32n, "operatorPubkeyOffset"),
|
|
654
|
+
uint64Word(BigInt(operatorPubkey.length), "operatorPubkeyLength"),
|
|
655
|
+
operatorPubkeyPadded
|
|
656
|
+
)
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
function encodeVoteClusterAdmitCalldata(args) {
|
|
660
|
+
const operatorId = expectLength2(toBytes(args.operatorId), 32, "operatorId");
|
|
661
|
+
const voterPubkey = expectLength2(
|
|
662
|
+
toBytes(args.voterPubkey),
|
|
663
|
+
NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
664
|
+
"voterPubkey"
|
|
665
|
+
);
|
|
666
|
+
const voterPubkeyPadded = padToWord(voterPubkey);
|
|
667
|
+
return bytesToHex(
|
|
668
|
+
concatBytes(
|
|
669
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.voteClusterAdmit),
|
|
670
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
671
|
+
operatorId,
|
|
672
|
+
uint64Word(3n * 32n, "voterPubkeyOffset"),
|
|
673
|
+
uint64Word(BigInt(voterPubkey.length), "voterPubkeyLength"),
|
|
674
|
+
voterPubkeyPadded
|
|
675
|
+
)
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
function encodeCancelClusterJoinCalldata(args) {
|
|
679
|
+
return bytesToHex(
|
|
680
|
+
concatBytes(
|
|
681
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.cancelClusterJoin),
|
|
682
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
683
|
+
expectLength2(toBytes(args.operatorId), 32, "operatorId")
|
|
684
|
+
)
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
function encodeExpireClusterJoinCalldata(args) {
|
|
688
|
+
return bytesToHex(
|
|
689
|
+
concatBytes(
|
|
690
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.expireClusterJoin),
|
|
691
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
692
|
+
expectLength2(toBytes(args.operatorId), 32, "operatorId")
|
|
693
|
+
)
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
function encodeGetClusterJoinRequestCalldata(args) {
|
|
697
|
+
return bytesToHex(
|
|
698
|
+
concatBytes(
|
|
699
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.getClusterJoinRequest),
|
|
700
|
+
uint32Word(toUint32(args.clusterId, "clusterId")),
|
|
701
|
+
expectLength2(toBytes(args.operatorId), 32, "operatorId")
|
|
702
|
+
)
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
function formClusterMessage(activePubkeys, standbyPubkeys) {
|
|
706
|
+
const active = expectLength2(
|
|
707
|
+
toBytes(activePubkeys),
|
|
708
|
+
NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT * NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
709
|
+
"activePubkeys"
|
|
710
|
+
);
|
|
711
|
+
const standby = expectLength2(
|
|
712
|
+
toBytes(standbyPubkeys),
|
|
713
|
+
NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT * NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
714
|
+
"standbyPubkeys"
|
|
715
|
+
);
|
|
716
|
+
return blake3(
|
|
717
|
+
concatBytes(
|
|
718
|
+
new TextEncoder().encode(NODE_REGISTRY_FORM_CLUSTER_MESSAGE_DOMAIN),
|
|
719
|
+
u16BeBytes(NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT),
|
|
720
|
+
u16BeBytes(NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT),
|
|
721
|
+
u16BeBytes(NODE_REGISTRY_FORM_CLUSTER_THRESHOLD),
|
|
722
|
+
u32BeBytes(active.length),
|
|
723
|
+
active,
|
|
724
|
+
u32BeBytes(standby.length),
|
|
725
|
+
standby
|
|
726
|
+
)
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function formClusterMessageHex(activePubkeys, standbyPubkeys) {
|
|
730
|
+
return bytesToHex(formClusterMessage(activePubkeys, standbyPubkeys));
|
|
731
|
+
}
|
|
732
|
+
function encodeFormClusterCalldata(args) {
|
|
733
|
+
const activePubkeys = expectLength2(
|
|
734
|
+
toBytes(args.activePubkeys),
|
|
735
|
+
NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT * NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
736
|
+
"activePubkeys"
|
|
737
|
+
);
|
|
738
|
+
const standbyPubkeys = expectLength2(
|
|
739
|
+
toBytes(args.standbyPubkeys),
|
|
740
|
+
NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT * NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
|
|
741
|
+
"standbyPubkeys"
|
|
742
|
+
);
|
|
743
|
+
const signatures = expectLength2(
|
|
744
|
+
toBytes(args.signatures),
|
|
745
|
+
NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT * NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES,
|
|
746
|
+
"signatures"
|
|
747
|
+
);
|
|
748
|
+
const activePadded = padToWord(activePubkeys);
|
|
749
|
+
const standbyPadded = padToWord(standbyPubkeys);
|
|
750
|
+
const signaturesPadded = padToWord(signatures);
|
|
751
|
+
const activeOffset = 3n * 32n;
|
|
752
|
+
const standbyOffset = activeOffset + 32n + BigInt(activePadded.length);
|
|
753
|
+
const signaturesOffset = standbyOffset + 32n + BigInt(standbyPadded.length);
|
|
754
|
+
return bytesToHex(
|
|
755
|
+
concatBytes(
|
|
756
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.formCluster),
|
|
757
|
+
uint64Word(activeOffset, "activePubkeysOffset"),
|
|
758
|
+
uint64Word(standbyOffset, "standbyPubkeysOffset"),
|
|
759
|
+
uint64Word(signaturesOffset, "signaturesOffset"),
|
|
760
|
+
uint64Word(BigInt(activePubkeys.length), "activePubkeysLength"),
|
|
761
|
+
activePadded,
|
|
762
|
+
uint64Word(BigInt(standbyPubkeys.length), "standbyPubkeysLength"),
|
|
763
|
+
standbyPadded,
|
|
764
|
+
uint64Word(BigInt(signatures.length), "signaturesLength"),
|
|
765
|
+
signaturesPadded
|
|
766
|
+
)
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
function decodeClusterJoinRequest(returnData) {
|
|
770
|
+
const bytes = expectLength2(toBytes(returnData), 8 * 32, "clusterJoinRequest");
|
|
771
|
+
const word = (i) => bytes.slice(i * 32, (i + 1) * 32);
|
|
772
|
+
const statusCode = numberFromWord(word(5), "status", 255);
|
|
773
|
+
return {
|
|
774
|
+
owner: bytesToHex(word(0).slice(12, 32)),
|
|
775
|
+
requestEpoch: u64FromWord(word(1)),
|
|
776
|
+
snapshotThreshold: numberFromWord(word(2), "snapshotThreshold", 65535),
|
|
777
|
+
snapshotN: numberFromWord(word(3), "snapshotN", 65535),
|
|
778
|
+
voteCount: numberFromWord(word(4), "voteCount", 65535),
|
|
779
|
+
statusCode,
|
|
780
|
+
status: clusterJoinRequestStatusLabel(statusCode),
|
|
781
|
+
bondLythoshi: uintFromWord(word(6)),
|
|
782
|
+
sealRosterPending: numberFromWord(word(7), "sealRosterPending", 1) === 1
|
|
783
|
+
};
|
|
784
|
+
}
|
|
614
785
|
function encodeReportServiceProbeCalldata(args) {
|
|
615
786
|
if (!isValidPublicServiceProbeMask(args.serviceMask)) {
|
|
616
787
|
throw new NodeRegistryError(
|
|
@@ -697,7 +868,9 @@ function deriveClusterAnchorAddress(roster, threshold) {
|
|
|
697
868
|
if (!Number.isInteger(threshold) || threshold < 0 || threshold > 65535) {
|
|
698
869
|
throw new NodeRegistryError("threshold must be a uint16");
|
|
699
870
|
}
|
|
700
|
-
const members = roster.map(
|
|
871
|
+
const members = roster.map(
|
|
872
|
+
(m, i) => expectLength2(toBytes(m), NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES, `roster[${i}]`)
|
|
873
|
+
);
|
|
701
874
|
members.sort(compareBytes);
|
|
702
875
|
const parts = [
|
|
703
876
|
new TextEncoder().encode(MULTISIG_ADDRESS_DERIVATION_DOMAIN),
|
|
@@ -722,6 +895,36 @@ function u64FromWord(word) {
|
|
|
722
895
|
}
|
|
723
896
|
return v;
|
|
724
897
|
}
|
|
898
|
+
function uintFromWord(word) {
|
|
899
|
+
let v = 0n;
|
|
900
|
+
for (const byte of word) {
|
|
901
|
+
v = v << 8n | BigInt(byte);
|
|
902
|
+
}
|
|
903
|
+
return v;
|
|
904
|
+
}
|
|
905
|
+
function numberFromWord(word, name, max) {
|
|
906
|
+
const value = uintFromWord(word);
|
|
907
|
+
if (value > BigInt(max)) {
|
|
908
|
+
throw new NodeRegistryError(`${name} must be <= ${max}`);
|
|
909
|
+
}
|
|
910
|
+
return Number(value);
|
|
911
|
+
}
|
|
912
|
+
function clusterJoinRequestStatusLabel(status) {
|
|
913
|
+
switch (status) {
|
|
914
|
+
case 0:
|
|
915
|
+
return "none";
|
|
916
|
+
case 1:
|
|
917
|
+
return "open";
|
|
918
|
+
case 2:
|
|
919
|
+
return "admitted";
|
|
920
|
+
case 3:
|
|
921
|
+
return "cancelled";
|
|
922
|
+
case 4:
|
|
923
|
+
return "expired";
|
|
924
|
+
default:
|
|
925
|
+
return "unknown";
|
|
926
|
+
}
|
|
927
|
+
}
|
|
725
928
|
function u64BeBytes(value) {
|
|
726
929
|
const out = new Uint8Array(8);
|
|
727
930
|
let n = value;
|
|
@@ -731,6 +934,16 @@ function u64BeBytes(value) {
|
|
|
731
934
|
}
|
|
732
935
|
return out;
|
|
733
936
|
}
|
|
937
|
+
function u32BeBytes(value) {
|
|
938
|
+
const n = expectUint32(value, "uint32");
|
|
939
|
+
return Uint8Array.from([n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, n & 255]);
|
|
940
|
+
}
|
|
941
|
+
function u16BeBytes(value) {
|
|
942
|
+
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
943
|
+
throw new NodeRegistryError("uint16 value out of range");
|
|
944
|
+
}
|
|
945
|
+
return Uint8Array.from([value >>> 8 & 255, value & 255]);
|
|
946
|
+
}
|
|
734
947
|
function compareBytes(a, b) {
|
|
735
948
|
const len = Math.min(a.length, b.length);
|
|
736
949
|
for (let i = 0; i < len; i++) {
|
|
@@ -753,6 +966,27 @@ function expectUint32(value, name) {
|
|
|
753
966
|
}
|
|
754
967
|
return value;
|
|
755
968
|
}
|
|
969
|
+
function toUint32(value, name) {
|
|
970
|
+
let parsed;
|
|
971
|
+
if (typeof value === "bigint") {
|
|
972
|
+
parsed = value;
|
|
973
|
+
} else if (typeof value === "number") {
|
|
974
|
+
if (!Number.isSafeInteger(value)) {
|
|
975
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
976
|
+
}
|
|
977
|
+
parsed = BigInt(value);
|
|
978
|
+
} else {
|
|
979
|
+
const trimmed = value.trim();
|
|
980
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
981
|
+
throw new NodeRegistryError(`${name} must be a decimal uint32`);
|
|
982
|
+
}
|
|
983
|
+
parsed = BigInt(trimmed);
|
|
984
|
+
}
|
|
985
|
+
if (parsed < 0n || parsed > 0xffffffffn) {
|
|
986
|
+
throw new NodeRegistryError(`${name} must fit uint32`);
|
|
987
|
+
}
|
|
988
|
+
return Number(parsed);
|
|
989
|
+
}
|
|
756
990
|
function uint32Word(value) {
|
|
757
991
|
const out = new Uint8Array(32);
|
|
758
992
|
const n = expectUint32(value, "uint32");
|
|
@@ -895,26 +1129,15 @@ function bigintToBeBytes(value, bytes, label) {
|
|
|
895
1129
|
}
|
|
896
1130
|
return out;
|
|
897
1131
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
return
|
|
906
|
-
|
|
907
|
-
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
908
|
-
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "encrypted mempool submission unavailable until MB-3 threshold decryption is active";
|
|
912
|
-
async function buildEncryptedSubmission(_args) {
|
|
913
|
-
await Promise.resolve();
|
|
914
|
-
throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
|
|
915
|
-
}
|
|
916
|
-
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
917
|
-
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
1132
|
+
function parseBigint(value, label) {
|
|
1133
|
+
if (value === void 0) throw new Error(`${label} missing`);
|
|
1134
|
+
if (typeof value === "bigint") return value;
|
|
1135
|
+
if (typeof value === "number") {
|
|
1136
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error(`${label} must be a non-negative safe integer`);
|
|
1137
|
+
return BigInt(value);
|
|
1138
|
+
}
|
|
1139
|
+
if (value.startsWith("0x") || value.startsWith("0X")) return BigInt(value);
|
|
1140
|
+
return BigInt(value);
|
|
918
1141
|
}
|
|
919
1142
|
|
|
920
1143
|
// src/crypto/bincode.ts
|
|
@@ -976,6 +1199,645 @@ var BincodeWriter = class {
|
|
|
976
1199
|
}
|
|
977
1200
|
};
|
|
978
1201
|
|
|
1202
|
+
// src/crypto/tx.ts
|
|
1203
|
+
function encodeTransactionForHash(fields, tag) {
|
|
1204
|
+
const n = normalizeTxFields(fields);
|
|
1205
|
+
return concatBytes2(
|
|
1206
|
+
Uint8Array.of(tag),
|
|
1207
|
+
bigintToBeBytes(n.chainId, 8, "chainId"),
|
|
1208
|
+
bigintToBeBytes(n.nonce, 8, "nonce"),
|
|
1209
|
+
bigintToBeBytes(n.maxPriorityFeePerGas, 32, "maxPriorityFeePerGas"),
|
|
1210
|
+
bigintToBeBytes(n.maxFeePerGas, 32, "maxFeePerGas"),
|
|
1211
|
+
bigintToBeBytes(n.gasLimit, 8, "gasLimit"),
|
|
1212
|
+
n.to === null ? Uint8Array.of(0) : concatBytes2(Uint8Array.of(1), n.to),
|
|
1213
|
+
bigintToBeBytes(n.value, 32, "value"),
|
|
1214
|
+
bigintToBeBytes(BigInt(n.input.length), 4, "input.length"),
|
|
1215
|
+
n.input,
|
|
1216
|
+
new Uint8Array(4),
|
|
1217
|
+
// access_list length
|
|
1218
|
+
encodeExtensionsForHash(n.extensions)
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
function bincodeSignedTransaction(fields, signature, publicKey) {
|
|
1222
|
+
const n = normalizeTxFields(fields);
|
|
1223
|
+
const sig = expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature");
|
|
1224
|
+
const pk = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
1225
|
+
const w = new BincodeWriter();
|
|
1226
|
+
w.u64(n.chainId);
|
|
1227
|
+
w.u64(n.nonce);
|
|
1228
|
+
w.bytes(uint256Be(n.maxPriorityFeePerGas, "maxPriorityFeePerGas"));
|
|
1229
|
+
w.bytes(uint256Be(n.maxFeePerGas, "maxFeePerGas"));
|
|
1230
|
+
w.u64(n.gasLimit);
|
|
1231
|
+
if (n.to === null) {
|
|
1232
|
+
w.u8(0);
|
|
1233
|
+
} else {
|
|
1234
|
+
w.u8(1);
|
|
1235
|
+
w.bytes(n.to);
|
|
1236
|
+
}
|
|
1237
|
+
w.bytes(uint256Be(n.value, "value"));
|
|
1238
|
+
w.bytes(n.input);
|
|
1239
|
+
w.u64(0n);
|
|
1240
|
+
w.u64(BigInt(n.extensions.length));
|
|
1241
|
+
for (const ext of n.extensions) bincodeTypedExtensionInto(w, ext);
|
|
1242
|
+
bincodeMlDsa65OpaqueInto(w, sig);
|
|
1243
|
+
bincodeMlDsa65OpaqueInto(w, pk);
|
|
1244
|
+
return w.toBytes();
|
|
1245
|
+
}
|
|
1246
|
+
function normalizeTxFields(fields) {
|
|
1247
|
+
return {
|
|
1248
|
+
chainId: parseBigint(fields.chainId, "chainId"),
|
|
1249
|
+
nonce: parseBigint(fields.nonce, "nonce"),
|
|
1250
|
+
maxPriorityFeePerGas: parseBigint(fields.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
1251
|
+
maxFeePerGas: parseBigint(fields.maxFeePerGas, "maxFeePerGas"),
|
|
1252
|
+
gasLimit: parseBigint(fields.gasLimit, "gasLimit"),
|
|
1253
|
+
to: normalizeTo(fields.to),
|
|
1254
|
+
value: parseBigint(fields.value, "value"),
|
|
1255
|
+
input: normalizeBytes(fields.input ?? new Uint8Array(0), "input"),
|
|
1256
|
+
extensions: normalizeExtensions(fields.extensions)
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function normalizeTo(value) {
|
|
1260
|
+
if (value === null) return null;
|
|
1261
|
+
const bytes = normalizeBytes(value, "to");
|
|
1262
|
+
return expectBytes(bytes, 20, "to");
|
|
1263
|
+
}
|
|
1264
|
+
function normalizeBytes(value, label) {
|
|
1265
|
+
if (typeof value === "string") return hexToBytes2(value, label);
|
|
1266
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
1267
|
+
}
|
|
1268
|
+
function normalizeExtensions(value) {
|
|
1269
|
+
if (value === void 0) return [];
|
|
1270
|
+
return value.map((ext, index) => {
|
|
1271
|
+
if (!Number.isInteger(ext.kind) || ext.kind < 0 || ext.kind > 255) {
|
|
1272
|
+
throw new Error(`extensions[${index}].kind out of u8 range`);
|
|
1273
|
+
}
|
|
1274
|
+
const body = normalizeBytes("bodyHex" in ext ? ext.bodyHex : ext.body, `extensions[${index}].body`);
|
|
1275
|
+
if (body.length > 4294967295) {
|
|
1276
|
+
throw new Error(`extensions[${index}].body exceeds u32 length`);
|
|
1277
|
+
}
|
|
1278
|
+
return { kind: ext.kind, body };
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
function encodeExtensionsForHash(extensions) {
|
|
1282
|
+
const chunks = [bigintToBeBytes(BigInt(extensions.length), 4, "extensions.length")];
|
|
1283
|
+
for (const ext of extensions) {
|
|
1284
|
+
chunks.push(
|
|
1285
|
+
Uint8Array.of(ext.kind),
|
|
1286
|
+
bigintToBeBytes(BigInt(ext.body.length), 4, "extension.body.length"),
|
|
1287
|
+
ext.body
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
return concatBytes2(...chunks);
|
|
1291
|
+
}
|
|
1292
|
+
function uint256Be(value, label) {
|
|
1293
|
+
if (value < 0n || value >= 1n << 256n) throw new Error(`${label} out of u256 range`);
|
|
1294
|
+
const out = new Uint8Array(32);
|
|
1295
|
+
let v = value;
|
|
1296
|
+
for (let i = 31; i >= 0; i--) {
|
|
1297
|
+
out[i] = Number(v & 0xffn);
|
|
1298
|
+
v >>= 8n;
|
|
1299
|
+
}
|
|
1300
|
+
return out;
|
|
1301
|
+
}
|
|
1302
|
+
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
1303
|
+
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
1304
|
+
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
1305
|
+
w.bytes(raw);
|
|
1306
|
+
}
|
|
1307
|
+
function bincodeTypedExtensionInto(w, ext) {
|
|
1308
|
+
w.u8(ext.kind);
|
|
1309
|
+
w.bytes(ext.body);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// src/crypto/ml-dsa.ts
|
|
1313
|
+
var ML_DSA_65_SEED_LEN = 32;
|
|
1314
|
+
var ML_DSA_65_SIGNING_KEY_LEN = 4032;
|
|
1315
|
+
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
1316
|
+
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
1317
|
+
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
1318
|
+
var ENUM_VARIANT_INDEX_ML_DSA_65 = 5;
|
|
1319
|
+
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
1320
|
+
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
1321
|
+
var MlDsa65Backend = class _MlDsa65Backend {
|
|
1322
|
+
#secretKey;
|
|
1323
|
+
#publicKey;
|
|
1324
|
+
#addressBytes;
|
|
1325
|
+
constructor(secretKey, publicKey) {
|
|
1326
|
+
this.#secretKey = expectBytes(secretKey, ML_DSA_65_SIGNING_KEY_LEN, "ML-DSA-65 secret key").slice();
|
|
1327
|
+
this.#publicKey = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key").slice();
|
|
1328
|
+
this.#addressBytes = mlDsa65AddressBytes(this.#publicKey);
|
|
1329
|
+
}
|
|
1330
|
+
static fromSeed(seed) {
|
|
1331
|
+
const kp = ml_dsa65.keygen(expectBytes(seed, ML_DSA_65_SEED_LEN, "ML-DSA-65 seed"));
|
|
1332
|
+
return new _MlDsa65Backend(kp.secretKey, kp.publicKey);
|
|
1333
|
+
}
|
|
1334
|
+
publicKey() {
|
|
1335
|
+
return this.#publicKey.slice();
|
|
1336
|
+
}
|
|
1337
|
+
addressBytes() {
|
|
1338
|
+
return this.#addressBytes.slice();
|
|
1339
|
+
}
|
|
1340
|
+
getAddress() {
|
|
1341
|
+
return bytesToHex2(this.#addressBytes);
|
|
1342
|
+
}
|
|
1343
|
+
sign(message) {
|
|
1344
|
+
return ml_dsa65.sign(message, this.#secretKey, { extraEntropy: false });
|
|
1345
|
+
}
|
|
1346
|
+
signPrehash(digest) {
|
|
1347
|
+
return this.sign(expectBytes(digest, 32, "prehash"));
|
|
1348
|
+
}
|
|
1349
|
+
verify(message, signature) {
|
|
1350
|
+
return ml_dsa65.verify(
|
|
1351
|
+
expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature"),
|
|
1352
|
+
message,
|
|
1353
|
+
this.#publicKey
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
signEvmTx(fields) {
|
|
1357
|
+
const txHashPreimage = encodeTransactionForHash(fields, 1);
|
|
1358
|
+
const sighash = keccak_256(txHashPreimage);
|
|
1359
|
+
const signature = this.sign(sighash);
|
|
1360
|
+
const wireBytes = bincodeSignedTransaction(fields, signature, this.#publicKey);
|
|
1361
|
+
const txHash = keccak_256(
|
|
1362
|
+
concatBytes2(
|
|
1363
|
+
encodeTransactionForHash(fields, 2),
|
|
1364
|
+
signature,
|
|
1365
|
+
this.#publicKey
|
|
1366
|
+
)
|
|
1367
|
+
);
|
|
1368
|
+
return {
|
|
1369
|
+
wireHex: bytesToHex2(wireBytes).slice(2),
|
|
1370
|
+
wireBytes,
|
|
1371
|
+
sighash,
|
|
1372
|
+
txHash
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
1377
|
+
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
1378
|
+
}
|
|
1379
|
+
function mlDsa65AddressBytes(publicKey) {
|
|
1380
|
+
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
1381
|
+
return blake3(concatBytes2(
|
|
1382
|
+
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
1383
|
+
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
1384
|
+
bytes
|
|
1385
|
+
)).slice(0, 20);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// src/crypto/envelope.ts
|
|
1389
|
+
new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
1390
|
+
var MempoolClass = {
|
|
1391
|
+
Transfer: 0,
|
|
1392
|
+
ContractCall: 1,
|
|
1393
|
+
CLOBOp: 3};
|
|
1394
|
+
function bincodeNonceAad(aad) {
|
|
1395
|
+
const w = new BincodeWriter();
|
|
1396
|
+
w.bytes(expectBytes(aad.sender, 20, "NonceAad.sender"));
|
|
1397
|
+
w.u64(aad.nonce);
|
|
1398
|
+
w.u64(aad.chainId);
|
|
1399
|
+
w.enumVariant(aad.class);
|
|
1400
|
+
w.u128(aad.maxFeePerGas);
|
|
1401
|
+
w.u128(aad.maxPriorityFeePerGas);
|
|
1402
|
+
w.u64(aad.gasLimit);
|
|
1403
|
+
return w.toBytes();
|
|
1404
|
+
}
|
|
1405
|
+
function bincodeDecryptHint(hint) {
|
|
1406
|
+
const w = new BincodeWriter();
|
|
1407
|
+
w.u64(hint.epoch);
|
|
1408
|
+
w.u16(hint.scheme);
|
|
1409
|
+
return w.toBytes();
|
|
1410
|
+
}
|
|
1411
|
+
function bincodeEncryptedEnvelope(env) {
|
|
1412
|
+
const w = new BincodeWriter();
|
|
1413
|
+
w.rawBytes(bincodeNonceAad(env.nonceAad));
|
|
1414
|
+
w.bytes(env.ciphertext);
|
|
1415
|
+
w.rawBytes(bincodeDecryptHint(env.decryptionHint));
|
|
1416
|
+
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"));
|
|
1417
|
+
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"));
|
|
1418
|
+
w.bytes(expectBytes(env.sender, 20, "sender"));
|
|
1419
|
+
return w.toBytes();
|
|
1420
|
+
}
|
|
1421
|
+
function outerSigDigest(nonceAad, ciphertext, decryptionHint, senderPubkey) {
|
|
1422
|
+
const aad = bincodeNonceAad(nonceAad);
|
|
1423
|
+
const hint = bincodeDecryptHint(decryptionHint);
|
|
1424
|
+
return keccak_256(concatBytes2(aad, ciphertext, hint, expectBytes(senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey")));
|
|
1425
|
+
}
|
|
1426
|
+
function bincodeMlDsa65OpaqueInto2(w, raw) {
|
|
1427
|
+
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
1428
|
+
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
1429
|
+
w.bytes(raw);
|
|
1430
|
+
}
|
|
1431
|
+
var SEAL_EK_LEN = 1184;
|
|
1432
|
+
var SEAL_KEY_LEN = 32;
|
|
1433
|
+
var SEAL_NONCE_LEN = 12;
|
|
1434
|
+
var SEAL_COMMIT_LEN = 32;
|
|
1435
|
+
var SEAL_SECRET_LEN = 32;
|
|
1436
|
+
var SEAL_SHARE_LEN = 1 + SEAL_SECRET_LEN;
|
|
1437
|
+
var CLUSTER_MLKEM_SHAMIR = 3;
|
|
1438
|
+
var COMMIT_DOMAIN = new TextEncoder().encode("lythiumseal/commit/v1");
|
|
1439
|
+
var KEK_DOMAIN = new TextEncoder().encode("lythiumseal/kek/v1");
|
|
1440
|
+
var NONCE_DOMAIN = new TextEncoder().encode("lythiumseal/nonce/v1");
|
|
1441
|
+
var BODY_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/body/v1");
|
|
1442
|
+
var SHARE_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/share/v1");
|
|
1443
|
+
var ROSTER_DOMAIN = new TextEncoder().encode("lythiumseal/roster/v1");
|
|
1444
|
+
function cryptoRandomSource() {
|
|
1445
|
+
return {
|
|
1446
|
+
fillBytes(dest) {
|
|
1447
|
+
crypto.getRandomValues(dest);
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
function u32le(n) {
|
|
1452
|
+
const out = new Uint8Array(4);
|
|
1453
|
+
out[0] = n & 255;
|
|
1454
|
+
out[1] = n >>> 8 & 255;
|
|
1455
|
+
out[2] = n >>> 16 & 255;
|
|
1456
|
+
out[3] = n >>> 24 & 255;
|
|
1457
|
+
return out;
|
|
1458
|
+
}
|
|
1459
|
+
function u64le(n) {
|
|
1460
|
+
const out = new Uint8Array(8);
|
|
1461
|
+
let v = n;
|
|
1462
|
+
for (let i = 0; i < 8; i++) {
|
|
1463
|
+
out[i] = Number(v & 0xffn);
|
|
1464
|
+
v >>= 8n;
|
|
1465
|
+
}
|
|
1466
|
+
return out;
|
|
1467
|
+
}
|
|
1468
|
+
function framed(field2) {
|
|
1469
|
+
return concatBytes2(u32le(field2.length), field2);
|
|
1470
|
+
}
|
|
1471
|
+
function keyCommitment(key) {
|
|
1472
|
+
return shake256(concatBytes2(framed(COMMIT_DOMAIN), key), { dkLen: SEAL_COMMIT_LEN });
|
|
1473
|
+
}
|
|
1474
|
+
function deriveKek(sharedSecret, domain, clusterId, epoch, opIndex) {
|
|
1475
|
+
const input = concatBytes2(
|
|
1476
|
+
framed(KEK_DOMAIN),
|
|
1477
|
+
framed(sharedSecret),
|
|
1478
|
+
framed(domain),
|
|
1479
|
+
u32le(clusterId),
|
|
1480
|
+
u64le(epoch),
|
|
1481
|
+
Uint8Array.of(opIndex)
|
|
1482
|
+
);
|
|
1483
|
+
return shake256(input, { dkLen: SEAL_KEY_LEN });
|
|
1484
|
+
}
|
|
1485
|
+
function deriveNonce(domain, context) {
|
|
1486
|
+
const input = concatBytes2(framed(NONCE_DOMAIN), framed(domain), framed(context));
|
|
1487
|
+
return shake256(input, { dkLen: SEAL_NONCE_LEN });
|
|
1488
|
+
}
|
|
1489
|
+
function bodyAad(ctx, k, n) {
|
|
1490
|
+
return concatBytes2(
|
|
1491
|
+
BODY_AAD_DOMAIN,
|
|
1492
|
+
u32le(ctx.clusterId),
|
|
1493
|
+
u64le(ctx.epoch),
|
|
1494
|
+
Uint8Array.of(k),
|
|
1495
|
+
Uint8Array.of(n),
|
|
1496
|
+
ctx.rosterHash
|
|
1497
|
+
);
|
|
1498
|
+
}
|
|
1499
|
+
function shareAad(ctx, opIndex) {
|
|
1500
|
+
return concatBytes2(
|
|
1501
|
+
SHARE_AAD_DOMAIN,
|
|
1502
|
+
u32le(ctx.clusterId),
|
|
1503
|
+
u64le(ctx.epoch),
|
|
1504
|
+
Uint8Array.of(opIndex),
|
|
1505
|
+
ctx.rosterHash
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
function aeadSeal(key, nonce, plaintext, aad) {
|
|
1509
|
+
const cipher = chacha20poly1305(key, nonce, aad);
|
|
1510
|
+
const ct = cipher.encrypt(plaintext);
|
|
1511
|
+
return { nonce, ct, commitment: keyCommitment(key) };
|
|
1512
|
+
}
|
|
1513
|
+
function gfMul(a, b) {
|
|
1514
|
+
let product = 0;
|
|
1515
|
+
let x = a & 255;
|
|
1516
|
+
let y = b & 255;
|
|
1517
|
+
for (let i = 0; i < 8; i++) {
|
|
1518
|
+
const mask = -(y & 1) & 255;
|
|
1519
|
+
product ^= x & mask;
|
|
1520
|
+
const high = -(x >> 7 & 1) & 255;
|
|
1521
|
+
x = x << 1 & 255;
|
|
1522
|
+
x ^= 27 & high;
|
|
1523
|
+
y >>= 1;
|
|
1524
|
+
}
|
|
1525
|
+
return product & 255;
|
|
1526
|
+
}
|
|
1527
|
+
function polyEval(coeffs, x) {
|
|
1528
|
+
let acc = 0;
|
|
1529
|
+
for (let i = coeffs.length - 1; i >= 0; i--) {
|
|
1530
|
+
acc = gfMul(acc, x) ^ coeffs[i];
|
|
1531
|
+
}
|
|
1532
|
+
return acc & 255;
|
|
1533
|
+
}
|
|
1534
|
+
function shamirSplit(secret, t, n, rng) {
|
|
1535
|
+
const byteCoeffs = [];
|
|
1536
|
+
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
1537
|
+
const c = new Uint8Array(t);
|
|
1538
|
+
c[0] = secret[j];
|
|
1539
|
+
if (t > 1) {
|
|
1540
|
+
const tail = new Uint8Array(t - 1);
|
|
1541
|
+
rng.fillBytes(tail);
|
|
1542
|
+
c.set(tail, 1);
|
|
1543
|
+
}
|
|
1544
|
+
byteCoeffs.push(c);
|
|
1545
|
+
}
|
|
1546
|
+
const shares = [];
|
|
1547
|
+
for (let k = 0; k < n; k++) {
|
|
1548
|
+
const x = k + 1 & 255;
|
|
1549
|
+
const value = new Uint8Array(SEAL_SECRET_LEN);
|
|
1550
|
+
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
1551
|
+
value[j] = polyEval(byteCoeffs[j], x);
|
|
1552
|
+
}
|
|
1553
|
+
shares.push({ index: x, value });
|
|
1554
|
+
}
|
|
1555
|
+
return shares;
|
|
1556
|
+
}
|
|
1557
|
+
function shareToBytes(s) {
|
|
1558
|
+
const out = new Uint8Array(SEAL_SHARE_LEN);
|
|
1559
|
+
out[0] = s.index;
|
|
1560
|
+
out.set(s.value, 1);
|
|
1561
|
+
return out;
|
|
1562
|
+
}
|
|
1563
|
+
function sealRosterHash(keccak2562, clusterId, t, n, roster) {
|
|
1564
|
+
const chunks = [ROSTER_DOMAIN, u32le(clusterId), Uint8Array.of(t), Uint8Array.of(n)];
|
|
1565
|
+
for (const { operatorIndex, ek } of roster) {
|
|
1566
|
+
chunks.push(Uint8Array.of(operatorIndex), ek);
|
|
1567
|
+
}
|
|
1568
|
+
return keccak2562(concatBytes2(...chunks));
|
|
1569
|
+
}
|
|
1570
|
+
function encodeSealEnvelope(env) {
|
|
1571
|
+
const chunks = [];
|
|
1572
|
+
chunks.push(u32le(env.clusterId));
|
|
1573
|
+
chunks.push(u64le(env.epoch));
|
|
1574
|
+
chunks.push(expectBytes(env.rosterHash, 32, "rosterHash"));
|
|
1575
|
+
chunks.push(Uint8Array.of(env.t));
|
|
1576
|
+
chunks.push(Uint8Array.of(env.n));
|
|
1577
|
+
pushAeadBody(chunks, env.aeadBody);
|
|
1578
|
+
chunks.push(u64le(BigInt(env.recipients.length)));
|
|
1579
|
+
for (const r of env.recipients) {
|
|
1580
|
+
chunks.push(Uint8Array.of(r.operatorIndex));
|
|
1581
|
+
chunks.push(u64le(BigInt(r.kemCt.length)));
|
|
1582
|
+
chunks.push(r.kemCt);
|
|
1583
|
+
pushAeadBody(chunks, r.wrapped);
|
|
1584
|
+
}
|
|
1585
|
+
return concatBytes2(...chunks);
|
|
1586
|
+
}
|
|
1587
|
+
function pushAeadBody(chunks, body) {
|
|
1588
|
+
chunks.push(expectBytes(body.nonce, SEAL_NONCE_LEN, "aead nonce"));
|
|
1589
|
+
chunks.push(u64le(BigInt(body.ct.length)));
|
|
1590
|
+
chunks.push(body.ct);
|
|
1591
|
+
chunks.push(expectBytes(body.commitment, SEAL_COMMIT_LEN, "aead commitment"));
|
|
1592
|
+
}
|
|
1593
|
+
function sealToCluster(args) {
|
|
1594
|
+
const { plaintext, recipientEks, t, clusterId } = args;
|
|
1595
|
+
const epoch = args.epoch;
|
|
1596
|
+
const rosterHash = expectBytes(args.rosterHash, 32, "rosterHash");
|
|
1597
|
+
const rng = args.rng ?? cryptoRandomSource();
|
|
1598
|
+
const n = recipientEks.length;
|
|
1599
|
+
if (!Number.isInteger(t) || t < 1 || t > n || n < 1 || n > 255) {
|
|
1600
|
+
throw new Error(`invalid threshold/recipient count: t=${t} n=${n}`);
|
|
1601
|
+
}
|
|
1602
|
+
for (let i = 0; i < n; i++) {
|
|
1603
|
+
expectBytes(recipientEks[i], SEAL_EK_LEN, `recipientEks[${i}]`);
|
|
1604
|
+
}
|
|
1605
|
+
const ctx = { clusterId, epoch, rosterHash };
|
|
1606
|
+
const bodyKey = new Uint8Array(SEAL_KEY_LEN);
|
|
1607
|
+
rng.fillBytes(bodyKey);
|
|
1608
|
+
const aad = bodyAad(ctx, t, n);
|
|
1609
|
+
const bodyNonce = deriveNonce(new TextEncoder().encode("body"), aad);
|
|
1610
|
+
const aeadBody = aeadSeal(bodyKey, bodyNonce, plaintext, aad);
|
|
1611
|
+
const shares = shamirSplit(bodyKey, t, n, rng);
|
|
1612
|
+
const recipients = [];
|
|
1613
|
+
for (let i = 0; i < n; i++) {
|
|
1614
|
+
const opIndex = i + 1 & 255;
|
|
1615
|
+
const m = new Uint8Array(32);
|
|
1616
|
+
rng.fillBytes(m);
|
|
1617
|
+
const { cipherText: kemCt, sharedSecret } = ml_kem768.encapsulate(recipientEks[i], m);
|
|
1618
|
+
const kek = deriveKek(sharedSecret, rosterHash, clusterId, epoch, opIndex);
|
|
1619
|
+
const sAad = shareAad(ctx, opIndex);
|
|
1620
|
+
const wrapNonce = deriveNonce(new TextEncoder().encode("share"), sAad);
|
|
1621
|
+
const wrapped = aeadSeal(kek, wrapNonce, shareToBytes(shares[i]), sAad);
|
|
1622
|
+
recipients.push({ operatorIndex: opIndex, kemCt, wrapped });
|
|
1623
|
+
sharedSecret.fill(0);
|
|
1624
|
+
kek.fill(0);
|
|
1625
|
+
}
|
|
1626
|
+
bodyKey.fill(0);
|
|
1627
|
+
return {
|
|
1628
|
+
clusterId,
|
|
1629
|
+
epoch,
|
|
1630
|
+
rosterHash,
|
|
1631
|
+
t,
|
|
1632
|
+
n,
|
|
1633
|
+
aeadBody,
|
|
1634
|
+
recipients
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// src/crypto/seal.ts
|
|
1639
|
+
var CLUSTER_MLKEM_SHAMIR_ALGO = "cluster-mlkem768-shamir";
|
|
1640
|
+
function parseClusterSealKeys(source) {
|
|
1641
|
+
const n = source.roster.length;
|
|
1642
|
+
if (n === 0) {
|
|
1643
|
+
throw new Error("cluster seal roster is empty");
|
|
1644
|
+
}
|
|
1645
|
+
if (source.n !== n) {
|
|
1646
|
+
throw new Error(`cluster seal roster n=${source.n} disagrees with ${n} entries`);
|
|
1647
|
+
}
|
|
1648
|
+
if (!Number.isInteger(source.t) || source.t < 2 || source.t > n) {
|
|
1649
|
+
throw new Error(`cluster seal threshold t=${source.t} out of range 2..=${n}`);
|
|
1650
|
+
}
|
|
1651
|
+
const sorted = [...source.roster].sort((a, b) => a.operatorIndex - b.operatorIndex);
|
|
1652
|
+
const recipientEks = [];
|
|
1653
|
+
const hashInput = [];
|
|
1654
|
+
for (let i = 0; i < n; i++) {
|
|
1655
|
+
const entry = sorted[i];
|
|
1656
|
+
if (entry.operatorIndex !== i + 1) {
|
|
1657
|
+
throw new Error(
|
|
1658
|
+
`cluster seal roster operator indices must be 1..=${n}; got ${entry.operatorIndex} at slot ${i + 1}`
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
const ek = expectBytes(hexToBytes2(entry.mlKemEk, `operator ${entry.operatorIndex} mlKemEk`), SEAL_EK_LEN, `operator ${entry.operatorIndex} ek`);
|
|
1662
|
+
recipientEks.push(ek);
|
|
1663
|
+
hashInput.push({ operatorIndex: entry.operatorIndex, ek });
|
|
1664
|
+
}
|
|
1665
|
+
const recomputed = sealRosterHash(keccak256, source.clusterId, source.t, n, hashInput);
|
|
1666
|
+
if (source.rosterHash !== void 0) {
|
|
1667
|
+
const supplied = expectBytes(hexToBytes2(source.rosterHash, "rosterHash"), 32, "rosterHash");
|
|
1668
|
+
if (!bytesEqual(supplied, recomputed)) {
|
|
1669
|
+
throw new Error(
|
|
1670
|
+
`cluster seal roster hash mismatch: source ${bytesToHex2(supplied)} != recomputed ${bytesToHex2(recomputed)} (the roster hash does not commit to this ek set)`
|
|
1671
|
+
);
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return {
|
|
1675
|
+
algo: source.algo ?? CLUSTER_MLKEM_SHAMIR_ALGO,
|
|
1676
|
+
clusterId: source.clusterId,
|
|
1677
|
+
epoch: toBigInt(source.epoch),
|
|
1678
|
+
rosterHash: recomputed,
|
|
1679
|
+
t: source.t,
|
|
1680
|
+
n,
|
|
1681
|
+
recipientEks
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
async function sealTransaction(args) {
|
|
1685
|
+
const keys = args.clusterSealKeys;
|
|
1686
|
+
const senderPubkey = expectBytes(args.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey");
|
|
1687
|
+
const senderAddress = expectBytes(args.senderAddress, 20, "senderAddress");
|
|
1688
|
+
const env = sealToCluster({
|
|
1689
|
+
plaintext: args.signedTxBincode,
|
|
1690
|
+
recipientEks: keys.recipientEks,
|
|
1691
|
+
t: keys.t,
|
|
1692
|
+
clusterId: keys.clusterId,
|
|
1693
|
+
epoch: keys.epoch,
|
|
1694
|
+
rosterHash: keys.rosterHash,
|
|
1695
|
+
rng: args.rng
|
|
1696
|
+
});
|
|
1697
|
+
const ciphertext = encodeSealEnvelope(env);
|
|
1698
|
+
const decryptionHint = { epoch: keys.epoch, scheme: CLUSTER_MLKEM_SHAMIR };
|
|
1699
|
+
const digest = outerSigDigest(args.aad, ciphertext, decryptionHint, senderPubkey);
|
|
1700
|
+
const outerSignature = expectBytes(
|
|
1701
|
+
await args.signOuterDigest(digest),
|
|
1702
|
+
ML_DSA_65_SIGNATURE_LEN,
|
|
1703
|
+
"outerSignature"
|
|
1704
|
+
);
|
|
1705
|
+
const envelope = {
|
|
1706
|
+
nonceAad: args.aad,
|
|
1707
|
+
ciphertext,
|
|
1708
|
+
decryptionHint,
|
|
1709
|
+
senderPubkey,
|
|
1710
|
+
outerSignature,
|
|
1711
|
+
sender: senderAddress
|
|
1712
|
+
};
|
|
1713
|
+
const envelopeWireBytes = bincodeEncryptedEnvelope(envelope);
|
|
1714
|
+
return {
|
|
1715
|
+
envelopeWireHex: `0x${bytesToHex2(envelopeWireBytes).slice(2)}`,
|
|
1716
|
+
envelopeWireBytes,
|
|
1717
|
+
ciphertextBytes: ciphertext.length
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
function keccak256(input) {
|
|
1721
|
+
return keccak_256(input);
|
|
1722
|
+
}
|
|
1723
|
+
function toBigInt(value) {
|
|
1724
|
+
if (typeof value === "bigint") return value;
|
|
1725
|
+
return BigInt(value);
|
|
1726
|
+
}
|
|
1727
|
+
function bytesEqual(a, b) {
|
|
1728
|
+
if (a.length !== b.length) return false;
|
|
1729
|
+
for (let i = 0; i < a.length; i++) {
|
|
1730
|
+
if (a[i] !== b[i]) return false;
|
|
1731
|
+
}
|
|
1732
|
+
return true;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// src/crypto/submission.ts
|
|
1736
|
+
async function fetchEncryptionKey(client) {
|
|
1737
|
+
const result = await client.call(
|
|
1738
|
+
"lyth_getEncryptionKey",
|
|
1739
|
+
[]
|
|
1740
|
+
);
|
|
1741
|
+
return {
|
|
1742
|
+
algo: result.algo ?? "ml-kem-768",
|
|
1743
|
+
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
1744
|
+
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "private submission requires cluster seal keys; pass clusterSealKeysSource or enable lyth_getClusterSealKeys";
|
|
1748
|
+
async function buildEncryptedSubmission(args) {
|
|
1749
|
+
const signed = args.backend.signEvmTx(args.tx);
|
|
1750
|
+
const clusterSealKeys = await resolveClusterSealKeys(args);
|
|
1751
|
+
const aad = nonceAadForTx(args.tx, args.backend.addressBytes(), args.class);
|
|
1752
|
+
const sealed = await sealTransaction({
|
|
1753
|
+
signedTxBincode: signed.wireBytes,
|
|
1754
|
+
clusterSealKeys,
|
|
1755
|
+
aad,
|
|
1756
|
+
senderAddress: args.backend.addressBytes(),
|
|
1757
|
+
senderPubkey: args.backend.publicKey(),
|
|
1758
|
+
signOuterDigest: (digest) => args.backend.signPrehash(digest)
|
|
1759
|
+
});
|
|
1760
|
+
return {
|
|
1761
|
+
envelopeWireHex: sealed.envelopeWireHex,
|
|
1762
|
+
innerSighashHex: bytesToHex2(signed.sighash),
|
|
1763
|
+
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
1764
|
+
innerWireBytes: signed.wireBytes.length
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
1768
|
+
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
1769
|
+
}
|
|
1770
|
+
function buildPlaintextSubmission(args) {
|
|
1771
|
+
const signed = args.backend.signEvmTx(args.tx);
|
|
1772
|
+
return {
|
|
1773
|
+
signedTxWireHex: `0x${signed.wireHex}`,
|
|
1774
|
+
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
1775
|
+
innerSighashHex: bytesToHex2(signed.sighash),
|
|
1776
|
+
innerWireBytes: signed.wireBytes.length
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
async function submitPlaintextTransaction(client, signedTxWireHex, expectedTxHashHex) {
|
|
1780
|
+
const returned = await client.call("mesh_submitTx", [signedTxWireHex]);
|
|
1781
|
+
const returnedBytes = hexToBytes2(returned, "mesh_submitTx tx hash");
|
|
1782
|
+
if (returnedBytes.length !== 32) {
|
|
1783
|
+
throw new Error(
|
|
1784
|
+
`mesh_submitTx tx hash must be 32 bytes, got ${returnedBytes.length}`
|
|
1785
|
+
);
|
|
1786
|
+
}
|
|
1787
|
+
const expectedBytes = hexToBytes2(expectedTxHashHex, "expected tx hash");
|
|
1788
|
+
if (!bytesEqual2(returnedBytes, expectedBytes)) {
|
|
1789
|
+
throw new Error(
|
|
1790
|
+
`mesh_submitTx returned tx hash ${bytesToHex2(returnedBytes)} but the locally computed canonical hash is ${bytesToHex2(expectedBytes)}`
|
|
1791
|
+
);
|
|
1792
|
+
}
|
|
1793
|
+
return bytesToHex2(returnedBytes);
|
|
1794
|
+
}
|
|
1795
|
+
function bytesEqual2(a, b) {
|
|
1796
|
+
if (a.length !== b.length) return false;
|
|
1797
|
+
for (let i = 0; i < a.length; i++) {
|
|
1798
|
+
if (a[i] !== b[i]) return false;
|
|
1799
|
+
}
|
|
1800
|
+
return true;
|
|
1801
|
+
}
|
|
1802
|
+
async function resolveClusterSealKeys(args) {
|
|
1803
|
+
if (args.clusterSealKeys !== void 0) return args.clusterSealKeys;
|
|
1804
|
+
if (args.clusterSealKeysSource !== void 0) {
|
|
1805
|
+
return parseClusterSealKeys(args.clusterSealKeysSource);
|
|
1806
|
+
}
|
|
1807
|
+
if (args.client === void 0) {
|
|
1808
|
+
throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
|
|
1809
|
+
}
|
|
1810
|
+
const clusterId = args.clusterId ?? 0;
|
|
1811
|
+
const result = await args.client.call(
|
|
1812
|
+
"lyth_getClusterSealKeys",
|
|
1813
|
+
[clusterId]
|
|
1814
|
+
);
|
|
1815
|
+
return parseClusterSealKeys({ ...result, clusterId: result.clusterId ?? clusterId });
|
|
1816
|
+
}
|
|
1817
|
+
function nonceAadForTx(tx, sender, mempoolClass) {
|
|
1818
|
+
return {
|
|
1819
|
+
sender,
|
|
1820
|
+
nonce: parseBigint(tx.nonce, "nonce"),
|
|
1821
|
+
chainId: parseBigint(tx.chainId, "chainId"),
|
|
1822
|
+
class: mempoolClass ?? inferMempoolClass(tx),
|
|
1823
|
+
maxFeePerGas: parseBigint(tx.maxFeePerGas, "maxFeePerGas"),
|
|
1824
|
+
maxPriorityFeePerGas: parseBigint(tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
1825
|
+
gasLimit: parseBigint(tx.gasLimit, "gasLimit")
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
function inferMempoolClass(tx) {
|
|
1829
|
+
if (tx.to === null || hasInput(tx.input)) return MempoolClass.ContractCall;
|
|
1830
|
+
return MempoolClass.Transfer;
|
|
1831
|
+
}
|
|
1832
|
+
function hasInput(input) {
|
|
1833
|
+
if (input === void 0) return false;
|
|
1834
|
+
if (typeof input === "string") {
|
|
1835
|
+
const stripped = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
|
|
1836
|
+
return stripped.length > 0;
|
|
1837
|
+
}
|
|
1838
|
+
return input.length > 0;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
979
1841
|
// src/mrv.ts
|
|
980
1842
|
var MRV_FORMAT_VERSION = 1;
|
|
981
1843
|
var MRV_DEPLOY_PAYLOAD_VERSION = 1;
|
|
@@ -1477,6 +2339,7 @@ async function submitMrvCallNativeTx(client, backend, contractAddress, input, op
|
|
|
1477
2339
|
}
|
|
1478
2340
|
async function submitMrvEncryptedNativeTxGated(client, backend, plan, options) {
|
|
1479
2341
|
const submission = await buildEncryptedSubmission({
|
|
2342
|
+
backend,
|
|
1480
2343
|
tx: plan.tx,
|
|
1481
2344
|
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
1482
2345
|
class: options.class
|
|
@@ -1833,22 +2696,6 @@ function concatBytes3(...parts) {
|
|
|
1833
2696
|
function isIdentifier(value) {
|
|
1834
2697
|
return /^[a-z][a-z0-9_]*$/.test(value);
|
|
1835
2698
|
}
|
|
1836
|
-
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
1837
|
-
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
1838
|
-
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
1839
|
-
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
1840
|
-
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
1841
|
-
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
1842
|
-
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
1843
|
-
}
|
|
1844
|
-
function mlDsa65AddressBytes(publicKey) {
|
|
1845
|
-
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
1846
|
-
return blake3(concatBytes2(
|
|
1847
|
-
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
1848
|
-
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
1849
|
-
bytes
|
|
1850
|
-
)).slice(0, 20);
|
|
1851
|
-
}
|
|
1852
2699
|
|
|
1853
2700
|
// src/registry.ts
|
|
1854
2701
|
var BLS_PUBLIC_KEY_BYTE_LENGTH = 48;
|
|
@@ -1857,8 +2704,8 @@ var TESTNET_69420 = {
|
|
|
1857
2704
|
network: "testnet-69420",
|
|
1858
2705
|
display_name: "Monolythium Testnet",
|
|
1859
2706
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
1860
|
-
genesis_hash: "
|
|
1861
|
-
binary_sha: "
|
|
2707
|
+
genesis_hash: "0x6a2bb3c8a6701bedcddc0447583bb24f34b77310e3aa77c62ca303a453e9f7ba",
|
|
2708
|
+
binary_sha: "c283c75d",
|
|
1862
2709
|
rpc: [
|
|
1863
2710
|
{
|
|
1864
2711
|
url: "http://178.105.12.9:8545",
|
|
@@ -3445,11 +4292,15 @@ var RpcClient = class _RpcClient {
|
|
|
3445
4292
|
const params = status === void 0 ? operator == null ? [] : [operator] : [operator ?? null, status];
|
|
3446
4293
|
return this.call("lyth_getClusterResignations", params);
|
|
3447
4294
|
}
|
|
3448
|
-
/** `
|
|
4295
|
+
/** `lyth_getRoundCertificate` — round-advancement certificate. */
|
|
4296
|
+
async lythGetRoundCertificate(round) {
|
|
4297
|
+
return this.call("lyth_getRoundCertificate", [encodeRpcInteger(round)]);
|
|
4298
|
+
}
|
|
4299
|
+
/** @deprecated Use lythGetRoundCertificate. */
|
|
3449
4300
|
async lythGetBlsRoundCertificate(round) {
|
|
3450
|
-
return this.
|
|
4301
|
+
return this.lythGetRoundCertificate(round);
|
|
3451
4302
|
}
|
|
3452
|
-
/** `lyth_getLeaderCertificate` — leader-vote
|
|
4303
|
+
/** `lyth_getLeaderCertificate` — leader-vote certificate for a block ref. */
|
|
3453
4304
|
async lythGetLeaderCertificate(round, authority, digest) {
|
|
3454
4305
|
return this.call("lyth_getLeaderCertificate", [encodeRpcInteger(round), authority, digest]);
|
|
3455
4306
|
}
|
|
@@ -4047,7 +4898,9 @@ function normalizeOperatorInfo(value) {
|
|
|
4047
4898
|
(v, i) => parseRpcNumber(v, `operator info activeClusterIds[${i}]`)
|
|
4048
4899
|
),
|
|
4049
4900
|
operatorKeyFingerprint: parseStringNullable(row["operatorKeyFingerprint"]),
|
|
4050
|
-
|
|
4901
|
+
consensusKeyFingerprint: parseStringNullable(
|
|
4902
|
+
row["consensusKeyFingerprint"] ?? row["blsKeyFingerprint"]
|
|
4903
|
+
),
|
|
4051
4904
|
lifecycleState: String(row["lifecycleState"]),
|
|
4052
4905
|
capability: capability && typeof capability === "object" && !Array.isArray(capability) ? capability : {}
|
|
4053
4906
|
};
|
|
@@ -4056,7 +4909,7 @@ function normalizeClusterMember(value, label) {
|
|
|
4056
4909
|
const row = expectObject(value, label);
|
|
4057
4910
|
return {
|
|
4058
4911
|
operatorId: String(row["operatorId"]),
|
|
4059
|
-
|
|
4912
|
+
consensusPubkey: String(row["consensusPubkey"] ?? row["blsPubkey"]),
|
|
4060
4913
|
state: String(row["state"])
|
|
4061
4914
|
};
|
|
4062
4915
|
}
|
|
@@ -4122,7 +4975,7 @@ function normalizeOperatorAuthority(value) {
|
|
|
4122
4975
|
schemaVersion: parseRpcNumber(row["schemaVersion"], "operator authority schemaVersion"),
|
|
4123
4976
|
operatorId: String(row["operatorId"]),
|
|
4124
4977
|
authorityIndex: parseRpcNumber(row["authorityIndex"], "operator authority authorityIndex"),
|
|
4125
|
-
|
|
4978
|
+
consensusPubkey: String(row["consensusPubkey"] ?? row["blsPubkey"]),
|
|
4126
4979
|
active: Boolean(row["active"])
|
|
4127
4980
|
};
|
|
4128
4981
|
}
|
|
@@ -5868,7 +6721,7 @@ var NO_EVM_COMPACT_INCLUSION_TREE_ALGORITHM = "binary-keccak-receipt-tree";
|
|
|
5868
6721
|
var NO_EVM_ARCHIVE_PROOF_SCHEMA = "mono.no_evm_receipt_archive_binding.v1";
|
|
5869
6722
|
var NO_EVM_ARCHIVE_SIGNATURE_SCHEME = "mono.snapshot.sig.v1";
|
|
5870
6723
|
var NO_EVM_FINALITY_EVIDENCE_SCHEMA = "mono.no_evm_receipt_finality.v1";
|
|
5871
|
-
var NO_EVM_FINALITY_EVIDENCE_SOURCE = "
|
|
6724
|
+
var NO_EVM_FINALITY_EVIDENCE_SOURCE = "roundCertificate";
|
|
5872
6725
|
var EMPTY_ROOT_DOMAIN_BYTES = new TextEncoder().encode(NO_EVM_RECEIPTS_ROOT_DOMAIN);
|
|
5873
6726
|
var LEAF_DOMAIN_BYTES = new TextEncoder().encode(NO_EVM_RECEIPT_LEAF_DOMAIN);
|
|
5874
6727
|
var NODE_DOMAIN_BYTES = new TextEncoder().encode(NO_EVM_RECEIPT_NODE_DOMAIN);
|
|
@@ -6410,7 +7263,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
6410
7263
|
}
|
|
6411
7264
|
const actualRoot = computeNoEvmReceiptsRoot(receipts);
|
|
6412
7265
|
const expectedRoot = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
6413
|
-
if (!
|
|
7266
|
+
if (!bytesEqual3(expectedRoot, decodeHash(actualRoot, "computedReceiptsRoot"))) {
|
|
6414
7267
|
throw new NoEvmReceiptProofError(
|
|
6415
7268
|
"receipts_root_mismatch",
|
|
6416
7269
|
`receiptsRoot mismatch: expected ${proof.receiptsRoot}, computed ${actualRoot}`
|
|
@@ -6418,7 +7271,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
6418
7271
|
}
|
|
6419
7272
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
6420
7273
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
6421
|
-
if (!
|
|
7274
|
+
if (!bytesEqual3(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
6422
7275
|
throw new NoEvmReceiptProofError(
|
|
6423
7276
|
"target_receipt_hash_mismatch",
|
|
6424
7277
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -6475,7 +7328,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
6475
7328
|
const targetReceipt = decodeHexBytes(targetReceiptBytes, "targetReceiptBytes");
|
|
6476
7329
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
6477
7330
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
6478
|
-
if (!
|
|
7331
|
+
if (!bytesEqual3(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
6479
7332
|
throw new NoEvmReceiptProofError(
|
|
6480
7333
|
"target_receipt_hash_mismatch",
|
|
6481
7334
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -6486,7 +7339,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
6486
7339
|
compactProof.leafHash,
|
|
6487
7340
|
"compactInclusionProof.leafHash"
|
|
6488
7341
|
);
|
|
6489
|
-
if (!
|
|
7342
|
+
if (!bytesEqual3(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
6490
7343
|
throw new NoEvmReceiptProofError(
|
|
6491
7344
|
"compact_leaf_hash_mismatch",
|
|
6492
7345
|
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
@@ -6496,7 +7349,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
6496
7349
|
}
|
|
6497
7350
|
const compactRootBytes = decodeHash(compactProof.root, "compactInclusionProof.root");
|
|
6498
7351
|
const receiptsRootBytes = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
6499
|
-
if (!
|
|
7352
|
+
if (!bytesEqual3(receiptsRootBytes, compactRootBytes)) {
|
|
6500
7353
|
throw new NoEvmReceiptProofError(
|
|
6501
7354
|
"compact_root_mismatch",
|
|
6502
7355
|
`receiptsRoot must equal compactInclusionProof.root: receiptsRoot ${proof.receiptsRoot}, compact root ${compactProof.root}`
|
|
@@ -6519,7 +7372,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
6519
7372
|
siblingHashes,
|
|
6520
7373
|
pathSides
|
|
6521
7374
|
);
|
|
6522
|
-
if (!
|
|
7375
|
+
if (!bytesEqual3(actualRootBytes, compactRootBytes)) {
|
|
6523
7376
|
throw new NoEvmReceiptProofError(
|
|
6524
7377
|
"compact_path_mismatch",
|
|
6525
7378
|
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
@@ -6673,7 +7526,7 @@ function validateCoveringSnapshotObject(snapshot, archiveContentHash, proofBlock
|
|
|
6673
7526
|
"archiveProof.coveringSnapshot.checkpointTo must match blockHeight"
|
|
6674
7527
|
);
|
|
6675
7528
|
}
|
|
6676
|
-
if (!
|
|
7529
|
+
if (!bytesEqual3(checkpointContentHash, archiveContentHash)) {
|
|
6677
7530
|
throw new NoEvmReceiptProofError(
|
|
6678
7531
|
"invalid_proof_shape",
|
|
6679
7532
|
"archiveProof.coveringSnapshot.checkpointContentHash must match archiveProof.contentHash"
|
|
@@ -6872,7 +7725,7 @@ function validateFinalityBlockReference(blockReference, round, proofBlockHash) {
|
|
|
6872
7725
|
);
|
|
6873
7726
|
if (proofBlockHash !== void 0) {
|
|
6874
7727
|
const blockHash = decodeHash(proofBlockHash, "blockHash");
|
|
6875
|
-
if (!
|
|
7728
|
+
if (!bytesEqual3(digest, blockHash)) {
|
|
6876
7729
|
throw new NoEvmReceiptProofError(
|
|
6877
7730
|
"invalid_proof_shape",
|
|
6878
7731
|
"finalityEvidence.blockReference.digest must match blockHash"
|
|
@@ -7222,7 +8075,7 @@ function assertHashBytes(value, field2) {
|
|
|
7222
8075
|
function isRecord3(value) {
|
|
7223
8076
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7224
8077
|
}
|
|
7225
|
-
function
|
|
8078
|
+
function bytesEqual3(a, b) {
|
|
7226
8079
|
if (a.length !== b.length) return false;
|
|
7227
8080
|
let diff = 0;
|
|
7228
8081
|
for (let index = 0; index < a.length; index++) {
|
|
@@ -7430,6 +8283,307 @@ function assertWholeNumber(field2, value) {
|
|
|
7430
8283
|
throw new Error(`${field2} must be a whole number`);
|
|
7431
8284
|
}
|
|
7432
8285
|
}
|
|
8286
|
+
var PQM1_ALGO_TAG_MLDSA65 = 1;
|
|
8287
|
+
var PQM1_VERSION_V1 = 1;
|
|
8288
|
+
var PQM1_PAYLOAD_LEN = 32;
|
|
8289
|
+
var PQM1_V1_MNEMONIC_WORDS = 24;
|
|
8290
|
+
var PQM1_V1_MLDSA65_DOMAIN_TAG = "monolythium.pqm1.v1.mldsa65";
|
|
8291
|
+
var Pqm1Error = class extends Error {
|
|
8292
|
+
constructor(kind, message) {
|
|
8293
|
+
super(message);
|
|
8294
|
+
this.kind = kind;
|
|
8295
|
+
this.name = "Pqm1Error";
|
|
8296
|
+
}
|
|
8297
|
+
kind;
|
|
8298
|
+
};
|
|
8299
|
+
var DOMAIN_BYTES = new TextEncoder().encode(PQM1_V1_MLDSA65_DOMAIN_TAG);
|
|
8300
|
+
function normalizeMnemonic(mnemonic) {
|
|
8301
|
+
return mnemonic.trim().toLowerCase().replace(/\s+/g, " ");
|
|
8302
|
+
}
|
|
8303
|
+
function ensureSupportedPayload(bytes) {
|
|
8304
|
+
if (bytes.length !== PQM1_PAYLOAD_LEN) {
|
|
8305
|
+
throw new Pqm1Error("badPayloadLength", `PQM-1 payload must be ${PQM1_PAYLOAD_LEN} bytes, got ${bytes.length}`);
|
|
8306
|
+
}
|
|
8307
|
+
if (bytes[0] !== PQM1_ALGO_TAG_MLDSA65) {
|
|
8308
|
+
throw new Pqm1Error("unsupportedAlgorithm", `unsupported PQM-1 algorithm tag 0x${bytes[0].toString(16).padStart(2, "0")}`);
|
|
8309
|
+
}
|
|
8310
|
+
if (bytes[1] !== PQM1_VERSION_V1) {
|
|
8311
|
+
throw new Pqm1Error("unsupportedVersion", `unsupported PQM-1 version 0x${bytes[1].toString(16).padStart(2, "0")}`);
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
function parsePqm1Payload(payload) {
|
|
8315
|
+
const bytes = expectBytes(payload, PQM1_PAYLOAD_LEN, "PQM-1 payload").slice();
|
|
8316
|
+
ensureSupportedPayload(bytes);
|
|
8317
|
+
return {
|
|
8318
|
+
algoTag: PQM1_ALGO_TAG_MLDSA65,
|
|
8319
|
+
version: PQM1_VERSION_V1,
|
|
8320
|
+
entropy: bytes.slice(2),
|
|
8321
|
+
bytes
|
|
8322
|
+
};
|
|
8323
|
+
}
|
|
8324
|
+
function pqm1MnemonicToPayload(mnemonic) {
|
|
8325
|
+
const normalized = normalizeMnemonic(mnemonic);
|
|
8326
|
+
const words = normalized.length === 0 ? [] : normalized.split(" ");
|
|
8327
|
+
if (words.length !== PQM1_V1_MNEMONIC_WORDS) {
|
|
8328
|
+
throw new Pqm1Error("badWordCount", `PQM-1 mnemonic must be ${PQM1_V1_MNEMONIC_WORDS} words, got ${words.length}`);
|
|
8329
|
+
}
|
|
8330
|
+
let payload;
|
|
8331
|
+
try {
|
|
8332
|
+
payload = mnemonicToEntropy(normalized, wordlist);
|
|
8333
|
+
} catch (e) {
|
|
8334
|
+
throw new Pqm1Error("bip39Decode", `invalid PQM-1 mnemonic: ${e.message}`);
|
|
8335
|
+
}
|
|
8336
|
+
return parsePqm1Payload(payload);
|
|
8337
|
+
}
|
|
8338
|
+
function derivePqm1MlDsa65SeedFromPayload(payload) {
|
|
8339
|
+
const parsed = parsePqm1Payload(payload);
|
|
8340
|
+
return shake256(concatBytes2(DOMAIN_BYTES, parsed.bytes), { dkLen: ML_DSA_65_SEED_LEN });
|
|
8341
|
+
}
|
|
8342
|
+
function pqm1MnemonicToMlDsa65Seed(mnemonic) {
|
|
8343
|
+
return derivePqm1MlDsa65SeedFromPayload(pqm1MnemonicToPayload(mnemonic).bytes);
|
|
8344
|
+
}
|
|
8345
|
+
function pqm1MnemonicToMlDsa65Backend(mnemonic) {
|
|
8346
|
+
return MlDsa65Backend.fromSeed(pqm1MnemonicToMlDsa65Seed(mnemonic));
|
|
8347
|
+
}
|
|
8348
|
+
|
|
8349
|
+
// src/cluster-join.ts
|
|
8350
|
+
var DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
8351
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
8352
|
+
var MAX_UINT32 = (1n << 32n) - 1n;
|
|
8353
|
+
function deriveClusterJoinOperatorId(operatorPubkey) {
|
|
8354
|
+
return bytesToHex2(blake3(normalizeConsensusPubkey(operatorPubkey, "operatorPubkey")));
|
|
8355
|
+
}
|
|
8356
|
+
function clusterJoinRequestExists(view) {
|
|
8357
|
+
return view.status !== "none" || view.owner.toLowerCase() !== ZERO_ADDRESS || view.bondLythoshi !== 0n;
|
|
8358
|
+
}
|
|
8359
|
+
async function readClusterJoinRequest(client, args) {
|
|
8360
|
+
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
8361
|
+
const operatorId = normalizeOperatorId(args.operatorId);
|
|
8362
|
+
const envelope = await client.call("lyth_getClusterJoinRequest", [
|
|
8363
|
+
Number(clusterId),
|
|
8364
|
+
operatorId
|
|
8365
|
+
]);
|
|
8366
|
+
return adaptNativeClusterJoinRequest(envelope.request);
|
|
8367
|
+
}
|
|
8368
|
+
async function preflightClusterJoinRequest(client, args) {
|
|
8369
|
+
try {
|
|
8370
|
+
return await readClusterJoinRequest(client, args);
|
|
8371
|
+
} catch (cause) {
|
|
8372
|
+
throw new Error(
|
|
8373
|
+
`CJ-1 lyth_getClusterJoinRequest is not exposed or failed on the connected chain: ${errorMessage(cause)}`
|
|
8374
|
+
);
|
|
8375
|
+
}
|
|
8376
|
+
}
|
|
8377
|
+
async function previewRequestClusterJoin(client, args) {
|
|
8378
|
+
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
8379
|
+
try {
|
|
8380
|
+
return await client.call("lyth_previewRequestClusterJoin", [{
|
|
8381
|
+
from: args.from,
|
|
8382
|
+
clusterId: Number(clusterId),
|
|
8383
|
+
operatorPubkey: bytesToHex2(normalizeConsensusPubkey(args.operatorPubkey, "operatorPubkey")),
|
|
8384
|
+
bondLythoshi: parseU256(args.bondLythoshi, "bondLythoshi").toString(10)
|
|
8385
|
+
}]);
|
|
8386
|
+
} catch (cause) {
|
|
8387
|
+
throw new Error(
|
|
8388
|
+
`CJ-1 request preview is not exposed or failed on the connected chain: ${errorMessage(cause)}`
|
|
8389
|
+
);
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8392
|
+
async function previewVoteClusterAdmit(client, args) {
|
|
8393
|
+
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
8394
|
+
try {
|
|
8395
|
+
return await client.call("lyth_previewVoteClusterAdmit", [{
|
|
8396
|
+
from: args.from,
|
|
8397
|
+
clusterId: Number(clusterId),
|
|
8398
|
+
operatorId: normalizeOperatorId(args.operatorId),
|
|
8399
|
+
voterPubkey: bytesToHex2(normalizeConsensusPubkey(args.voterPubkey, "voterPubkey"))
|
|
8400
|
+
}]);
|
|
8401
|
+
} catch (cause) {
|
|
8402
|
+
throw new Error(
|
|
8403
|
+
`CJ-1 admit-vote preview is not exposed or failed on the connected chain: ${errorMessage(cause)}`
|
|
8404
|
+
);
|
|
8405
|
+
}
|
|
8406
|
+
}
|
|
8407
|
+
function resolveClusterJoinExecutionFee(quote, options = {}) {
|
|
8408
|
+
const quoted = parseBigint(quote.executionUnitPriceLythoshi, "executionUnitPriceLythoshi");
|
|
8409
|
+
const floor = options.minPriceLythoshi === void 0 ? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI : parseBigint(options.minPriceLythoshi, "minPriceLythoshi");
|
|
8410
|
+
const multiplier = options.safetyMultiplier === void 0 ? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER : parseBigint(options.safetyMultiplier, "safetyMultiplier");
|
|
8411
|
+
if (multiplier <= 0n) throw new Error("safetyMultiplier must be greater than zero");
|
|
8412
|
+
const base = quoted > floor ? quoted : floor;
|
|
8413
|
+
const maxFeePerGas = base * multiplier;
|
|
8414
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
8415
|
+
return {
|
|
8416
|
+
maxFeePerGas,
|
|
8417
|
+
maxPriorityFeePerGas: tip,
|
|
8418
|
+
gasLimit: options.executionUnitLimit ?? DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT
|
|
8419
|
+
};
|
|
8420
|
+
}
|
|
8421
|
+
function buildRequestClusterJoinTxFields(args) {
|
|
8422
|
+
return {
|
|
8423
|
+
chainId: args.chainId,
|
|
8424
|
+
nonce: args.nonce,
|
|
8425
|
+
maxFeePerGas: parseBigint(args.fee.maxFeePerGas, "maxFeePerGas"),
|
|
8426
|
+
maxPriorityFeePerGas: parseBigint(args.fee.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
8427
|
+
gasLimit: parseBigint(
|
|
8428
|
+
args.fee.gasLimit ?? DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT,
|
|
8429
|
+
"gasLimit"
|
|
8430
|
+
),
|
|
8431
|
+
to: nodeRegistryAddressHex(),
|
|
8432
|
+
value: parseU256(args.bondLythoshi, "bondLythoshi"),
|
|
8433
|
+
input: encodeRequestClusterJoinCalldata({
|
|
8434
|
+
clusterId: args.clusterId,
|
|
8435
|
+
operatorPubkey: normalizeConsensusPubkey(args.operatorPubkey, "operatorPubkey")
|
|
8436
|
+
})
|
|
8437
|
+
};
|
|
8438
|
+
}
|
|
8439
|
+
function buildVoteClusterAdmitTxFields(args) {
|
|
8440
|
+
return {
|
|
8441
|
+
chainId: args.chainId,
|
|
8442
|
+
nonce: args.nonce,
|
|
8443
|
+
maxFeePerGas: parseBigint(args.fee.maxFeePerGas, "maxFeePerGas"),
|
|
8444
|
+
maxPriorityFeePerGas: parseBigint(args.fee.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
8445
|
+
gasLimit: parseBigint(
|
|
8446
|
+
args.fee.gasLimit ?? DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT,
|
|
8447
|
+
"gasLimit"
|
|
8448
|
+
),
|
|
8449
|
+
to: nodeRegistryAddressHex(),
|
|
8450
|
+
value: 0n,
|
|
8451
|
+
input: encodeVoteClusterAdmitCalldata({
|
|
8452
|
+
clusterId: args.clusterId,
|
|
8453
|
+
operatorId: normalizeOperatorId(args.operatorId),
|
|
8454
|
+
voterPubkey: normalizeConsensusPubkey(args.voterPubkey, "voterPubkey")
|
|
8455
|
+
})
|
|
8456
|
+
};
|
|
8457
|
+
}
|
|
8458
|
+
async function submitRequestClusterJoin(args) {
|
|
8459
|
+
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
8460
|
+
const operatorPubkey = normalizeConsensusPubkey(args.operatorPubkey, "operatorPubkey");
|
|
8461
|
+
const operatorIdHex = deriveClusterJoinOperatorId(operatorPubkey);
|
|
8462
|
+
const backend = pqm1MnemonicToMlDsa65Backend(args.mnemonic);
|
|
8463
|
+
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
8464
|
+
const preview = await previewRequestClusterJoin(args.client, {
|
|
8465
|
+
from: senderAddress,
|
|
8466
|
+
clusterId,
|
|
8467
|
+
operatorPubkey,
|
|
8468
|
+
bondLythoshi: args.bondLythoshi
|
|
8469
|
+
});
|
|
8470
|
+
assertPreviewOk("requestClusterJoin", preview);
|
|
8471
|
+
const [chainId, nonce, quote] = await Promise.all([
|
|
8472
|
+
args.client.ethChainId(),
|
|
8473
|
+
args.client.lythGetTransactionCount(senderAddress),
|
|
8474
|
+
args.client.lythExecutionUnitPrice()
|
|
8475
|
+
]);
|
|
8476
|
+
const tx = buildRequestClusterJoinTxFields({
|
|
8477
|
+
chainId,
|
|
8478
|
+
nonce,
|
|
8479
|
+
fee: resolveClusterJoinExecutionFee(quote, args),
|
|
8480
|
+
clusterId,
|
|
8481
|
+
operatorPubkey,
|
|
8482
|
+
bondLythoshi: args.bondLythoshi
|
|
8483
|
+
});
|
|
8484
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
8485
|
+
}
|
|
8486
|
+
async function submitVoteClusterAdmit(args) {
|
|
8487
|
+
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
8488
|
+
const operatorIdHex = normalizeOperatorId(args.operatorId);
|
|
8489
|
+
const backend = pqm1MnemonicToMlDsa65Backend(args.mnemonic);
|
|
8490
|
+
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
8491
|
+
const preview = await previewVoteClusterAdmit(args.client, {
|
|
8492
|
+
from: senderAddress,
|
|
8493
|
+
clusterId,
|
|
8494
|
+
operatorId: operatorIdHex,
|
|
8495
|
+
voterPubkey: args.voterPubkey
|
|
8496
|
+
});
|
|
8497
|
+
assertPreviewOk("voteClusterAdmit", preview);
|
|
8498
|
+
const [chainId, nonce, quote] = await Promise.all([
|
|
8499
|
+
args.client.ethChainId(),
|
|
8500
|
+
args.client.lythGetTransactionCount(senderAddress),
|
|
8501
|
+
args.client.lythExecutionUnitPrice()
|
|
8502
|
+
]);
|
|
8503
|
+
const tx = buildVoteClusterAdmitTxFields({
|
|
8504
|
+
chainId,
|
|
8505
|
+
nonce,
|
|
8506
|
+
fee: resolveClusterJoinExecutionFee(quote, args),
|
|
8507
|
+
clusterId,
|
|
8508
|
+
operatorId: operatorIdHex,
|
|
8509
|
+
voterPubkey: args.voterPubkey
|
|
8510
|
+
});
|
|
8511
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
8512
|
+
}
|
|
8513
|
+
async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex) {
|
|
8514
|
+
const plaintext = buildPlaintextSubmission({ backend, tx });
|
|
8515
|
+
const txHash = await submitPlaintextTransaction(
|
|
8516
|
+
client,
|
|
8517
|
+
plaintext.signedTxWireHex,
|
|
8518
|
+
plaintext.innerTxHashHex
|
|
8519
|
+
);
|
|
8520
|
+
return {
|
|
8521
|
+
txHash,
|
|
8522
|
+
clusterId: clusterId.toString(10),
|
|
8523
|
+
operatorIdHex,
|
|
8524
|
+
innerSighashHex: plaintext.innerSighashHex,
|
|
8525
|
+
signedTxWireBytes: plaintext.innerWireBytes
|
|
8526
|
+
};
|
|
8527
|
+
}
|
|
8528
|
+
function adaptNativeClusterJoinRequest(request) {
|
|
8529
|
+
return {
|
|
8530
|
+
owner: request.owner ?? ZERO_ADDRESS,
|
|
8531
|
+
requestEpoch: parseBigint(request.requestEpoch, "requestEpoch"),
|
|
8532
|
+
requestNonce: request.requestNonce === void 0 ? void 0 : parseBigint(request.requestNonce, "requestNonce"),
|
|
8533
|
+
snapshotThreshold: request.snapshotThreshold,
|
|
8534
|
+
snapshotN: request.snapshotN,
|
|
8535
|
+
voteCount: request.voteCount,
|
|
8536
|
+
statusCode: request.statusCode,
|
|
8537
|
+
status: clusterJoinStatus(request.status),
|
|
8538
|
+
bondLythoshi: parseBigint(request.bondLythoshi, "bondLythoshi"),
|
|
8539
|
+
sealRosterPending: request.sealRosterPending
|
|
8540
|
+
};
|
|
8541
|
+
}
|
|
8542
|
+
function clusterJoinStatus(status) {
|
|
8543
|
+
switch (status) {
|
|
8544
|
+
case "none":
|
|
8545
|
+
case "open":
|
|
8546
|
+
case "admitted":
|
|
8547
|
+
case "cancelled":
|
|
8548
|
+
case "expired":
|
|
8549
|
+
return status;
|
|
8550
|
+
default:
|
|
8551
|
+
return "unknown";
|
|
8552
|
+
}
|
|
8553
|
+
}
|
|
8554
|
+
function previewError(action, preview) {
|
|
8555
|
+
const reason = preview.reason ? `: ${preview.reason}` : "";
|
|
8556
|
+
const message = preview.message ? ` (${preview.message})` : "";
|
|
8557
|
+
return new Error(`${action} preview rejected${reason}${message}`);
|
|
8558
|
+
}
|
|
8559
|
+
function assertPreviewOk(action, preview) {
|
|
8560
|
+
if (!preview.ok) throw previewError(action, preview);
|
|
8561
|
+
}
|
|
8562
|
+
function normalizeConsensusPubkey(value, label) {
|
|
8563
|
+
const bytes = typeof value === "string" ? hexToBytes2(value, label) : value;
|
|
8564
|
+
return expectBytes(bytes, NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES, label).slice();
|
|
8565
|
+
}
|
|
8566
|
+
function normalizeOperatorId(value) {
|
|
8567
|
+
const bytes = typeof value === "string" ? hexToBytes2(value, "operatorId") : value;
|
|
8568
|
+
return bytesToHex2(expectBytes(bytes, 32, "operatorId"));
|
|
8569
|
+
}
|
|
8570
|
+
function parseUint32(value, label) {
|
|
8571
|
+
const parsed = parseBigint(value, label);
|
|
8572
|
+
if (parsed < 0n || parsed > MAX_UINT32) {
|
|
8573
|
+
throw new Error(`${label} out of 32-bit range`);
|
|
8574
|
+
}
|
|
8575
|
+
return parsed;
|
|
8576
|
+
}
|
|
8577
|
+
function parseU256(value, label) {
|
|
8578
|
+
const parsed = parseBigint(value, label);
|
|
8579
|
+
if (parsed < 0n || parsed >= 1n << 256n) {
|
|
8580
|
+
throw new Error(`${label} out of 256-bit range`);
|
|
8581
|
+
}
|
|
8582
|
+
return parsed;
|
|
8583
|
+
}
|
|
8584
|
+
function errorMessage(cause) {
|
|
8585
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
8586
|
+
}
|
|
7433
8587
|
var ORACLE_EVENT_SIGS = {
|
|
7434
8588
|
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
7435
8589
|
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
@@ -8398,11 +9552,6 @@ function wordToBigint(word) {
|
|
|
8398
9552
|
}
|
|
8399
9553
|
return out;
|
|
8400
9554
|
}
|
|
8401
|
-
new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
8402
|
-
var MempoolClass = {
|
|
8403
|
-
CLOBOp: 3};
|
|
8404
|
-
|
|
8405
|
-
// src/market-actions.ts
|
|
8406
9555
|
var CLOB_MARKET_ID_DOMAIN_TAG = 193;
|
|
8407
9556
|
var NATIVE_MARKET_MODULE_ADDRESS_BYTES = "0x4d41524b45545f4e41544956455f4d4f445f5631";
|
|
8408
9557
|
var NATIVE_MARKET_MODULE_ADDRESS = addressToTypedBech32(
|
|
@@ -9733,8 +10882,8 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
9733
10882
|
};
|
|
9734
10883
|
|
|
9735
10884
|
// src/index.ts
|
|
9736
|
-
var version = "0.
|
|
10885
|
+
var version = "0.4.2";
|
|
9737
10886
|
|
|
9738
|
-
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EMPTY_ROOT, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, FEED_ID_DOMAIN_TAG, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NAME_BASE_MULTIPLIER, NAME_FALLBACK_FEE_UNIT_LYTHOSHI, NAME_LABEL_MAX_LEN, NAME_LABEL_MIN_LEN, NAME_MAX_LEN, NAME_REGISTRY_SELECTORS, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS, NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS, NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NameRegistryError, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PENDING_CHANGE_KIND_CODES, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, categoryRoot, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, clusterApyPercent, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, computeQuoteLiquidity, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, denyRootFor, deriveClobMarketId, deriveClusterAnchorAddress, deriveFeedId, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, destinationRoot, encodeAttestDkgReshareCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNameAcceptTransferCall, encodeNameProposeTransferCall, encodeNameRegisterCall, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRecoverOperatorNodeCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nameLengthModifierX10, nameRegistrationCost, nameRegistryAddressHex, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, normalizePendingChangeKind, oracleAddressHex, oraclePriceToNumber, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseDkgResharePublicKeys, parseLythToLythoshi, parseNameCategory, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, setDestinationRoot, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, transactionFeeExposure, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
10887
|
+
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EMPTY_ROOT, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, FEED_ID_DOMAIN_TAG, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NAME_BASE_MULTIPLIER, NAME_FALLBACK_FEE_UNIT_LYTHOSHI, NAME_LABEL_MAX_LEN, NAME_LABEL_MIN_LEN, NAME_MAX_LEN, NAME_REGISTRY_SELECTORS, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES, NODE_REGISTRY_CONSENSUS_POP_BYTES, NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES, NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES, NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES, NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS, NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS, NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES, NODE_REGISTRY_FORM_CLUSTER_ACTIVE_COUNT, NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT, NODE_REGISTRY_FORM_CLUSTER_MESSAGE_DOMAIN, NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT, NODE_REGISTRY_FORM_CLUSTER_THRESHOLD, NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NameRegistryError, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PENDING_CHANGE_KIND_CODES, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, buildRequestClusterJoinTxFields, buildVoteClusterAdmitTxFields, categoryRoot, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, clusterApyPercent, clusterJoinRequestExists, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, computeQuoteLiquidity, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeClusterJoinRequest, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, denyRootFor, deriveClobMarketId, deriveClusterAnchorAddress, deriveClusterJoinOperatorId, deriveFeedId, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, destinationRoot, encodeAttestDkgReshareCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelClusterJoinCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeExpireClusterJoinCalldata, encodeFormClusterCalldata, encodeGetClusterJoinRequestCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNameAcceptTransferCall, encodeNameProposeTransferCall, encodeNameRegisterCall, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRecoverOperatorNodeCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeRequestClusterJoinCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeUndelegateCalldata, encodeVoteClusterAdmitCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formClusterMessage, formClusterMessageHex, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nameLengthModifierX10, nameRegistrationCost, nameRegistryAddressHex, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, normalizePendingChangeKind, oracleAddressHex, oraclePriceToNumber, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseDkgResharePublicKeys, parseLythToLythoshi, parseNameCategory, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, preflightClusterJoinRequest, previewRequestClusterJoin, previewVoteClusterAdmit, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, readClusterJoinRequest, requestSighash, requireTypedAddress, resolveClusterJoinExecutionFee, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, setDestinationRoot, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitRequestClusterJoin, submitSighash, submitVoteClusterAdmit, transactionFeeExposure, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
9739
10888
|
//# sourceMappingURL=index.js.map
|
|
9740
10889
|
//# sourceMappingURL=index.js.map
|