@monolythium/core-sdk 0.4.22 → 0.4.24
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 +6 -529
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +75 -3
- package/dist/crypto/index.d.ts +75 -3
- package/dist/crypto/index.js +6 -494
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +638 -1031
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7014 -392
- package/dist/index.d.ts +7014 -392
- package/dist/index.js +633 -1025
- package/dist/index.js.map +1 -1
- package/dist/ml-dsa-Drcmrw5h.d.cts +90 -0
- package/dist/ml-dsa-Drcmrw5h.d.ts +90 -0
- package/package.json +1 -1
- package/dist/submission-B4FmDnm_.d.cts +0 -7079
- package/dist/submission-B4FmDnm_.d.ts +0 -7079
package/dist/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { blake3 } from '@noble/hashes/blake3.js';
|
|
2
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';
|
|
6
3
|
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
|
|
7
4
|
import { bls12_381 } from '@noble/curves/bls12-381.js';
|
|
8
5
|
import { mnemonicToEntropy } from '@scure/bip39';
|
|
@@ -380,10 +377,6 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
380
377
|
formClusterV2: "0x" + selectorHex("formCluster(bytes,bytes,bytes,bytes)"),
|
|
381
378
|
/** `setOperatorDisplay(bytes32,string,string)` — owner-callable public display metadata. */
|
|
382
379
|
setOperatorDisplay: "0x" + selectorHex("setOperatorDisplay(bytes32,string,string)"),
|
|
383
|
-
/** `publishOperatorSealKey(bytes32,bytes)` — owner-callable LythiumSeal EK publication. */
|
|
384
|
-
publishOperatorSealKey: "0x" + selectorHex("publishOperatorSealKey(bytes32,bytes)"),
|
|
385
|
-
/** `getOperatorSealKey(bytes32)` view — returns the operator's published LythiumSeal EK. */
|
|
386
|
-
getOperatorSealKey: "0x" + selectorHex("getOperatorSealKey(bytes32)"),
|
|
387
380
|
/**
|
|
388
381
|
* `updateCharter(uint32,bytes,bytes,bytes)` — Component H live charter
|
|
389
382
|
* amendment (Law §6.8); re-signs a new 30-byte charter for a LIVE cluster
|
|
@@ -417,7 +410,6 @@ var NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
|
|
|
417
410
|
var NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES = 1952;
|
|
418
411
|
var NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES = 3309;
|
|
419
412
|
var NODE_REGISTRY_CONSENSUS_POP_BYTES = 3309;
|
|
420
|
-
var NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES = 1184;
|
|
421
413
|
var NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES = 96;
|
|
422
414
|
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = NODE_REGISTRY_DKG_ATTESTATION_SIG_BYTES;
|
|
423
415
|
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
@@ -684,43 +676,6 @@ function encodeSetOperatorDisplayCalldata(args) {
|
|
|
684
676
|
)
|
|
685
677
|
);
|
|
686
678
|
}
|
|
687
|
-
function encodePublishOperatorSealKeyCalldata(args) {
|
|
688
|
-
const peerId = expectLength2(toBytes(args.peerId), 32, "peerId");
|
|
689
|
-
const sealEk = expectNonZeroBytes(
|
|
690
|
-
expectLength2(toBytes(args.sealEk), NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES, "sealEk"),
|
|
691
|
-
"sealEk"
|
|
692
|
-
);
|
|
693
|
-
const sealEkPadded = padToWord(sealEk);
|
|
694
|
-
return bytesToHex(
|
|
695
|
-
concatBytes(
|
|
696
|
-
hexToBytes(NODE_REGISTRY_SELECTORS.publishOperatorSealKey),
|
|
697
|
-
peerId,
|
|
698
|
-
uint64Word(2n * 32n, "sealEkOffset"),
|
|
699
|
-
uint64Word(BigInt(sealEk.length), "sealEkLength"),
|
|
700
|
-
sealEkPadded
|
|
701
|
-
)
|
|
702
|
-
);
|
|
703
|
-
}
|
|
704
|
-
function encodeGetOperatorSealKeyCalldata(args) {
|
|
705
|
-
return bytesToHex(
|
|
706
|
-
concatBytes(
|
|
707
|
-
hexToBytes(NODE_REGISTRY_SELECTORS.getOperatorSealKey),
|
|
708
|
-
expectLength2(toBytes(args.operatorId), 32, "operatorId")
|
|
709
|
-
)
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
function decodeOperatorSealKey(returnData) {
|
|
713
|
-
const bytes = toBytes(returnData);
|
|
714
|
-
if (bytes.length === NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES) {
|
|
715
|
-
return bytesToHex(expectNonZeroBytes(bytes, "operatorSealKey"));
|
|
716
|
-
}
|
|
717
|
-
const sealEk = decodeDynamicBytesResult(
|
|
718
|
-
bytes,
|
|
719
|
-
NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES,
|
|
720
|
-
"operatorSealKey"
|
|
721
|
-
);
|
|
722
|
-
return bytesToHex(expectNonZeroBytes(sealEk, "operatorSealKey"));
|
|
723
|
-
}
|
|
724
679
|
function encodeCancelClusterJoinCalldata(args) {
|
|
725
680
|
return bytesToHex(
|
|
726
681
|
concatBytes(
|
|
@@ -1649,30 +1604,6 @@ function expectLength2(value, len, name) {
|
|
|
1649
1604
|
}
|
|
1650
1605
|
return value;
|
|
1651
1606
|
}
|
|
1652
|
-
function expectNonZeroBytes(value, name) {
|
|
1653
|
-
if (value.every((byte) => byte === 0)) {
|
|
1654
|
-
throw new NodeRegistryError(`${name} must not be all-zero`);
|
|
1655
|
-
}
|
|
1656
|
-
return value;
|
|
1657
|
-
}
|
|
1658
|
-
function decodeDynamicBytesResult(bytes, expectedLength, label) {
|
|
1659
|
-
if (bytes.length < 64) {
|
|
1660
|
-
throw new NodeRegistryError(`${label} return must be ABI-encoded dynamic bytes`);
|
|
1661
|
-
}
|
|
1662
|
-
const offset = uintFromWord(bytes.slice(0, 32));
|
|
1663
|
-
if (offset !== 32n) {
|
|
1664
|
-
throw new NodeRegistryError(`${label} return offset must be 0x20`);
|
|
1665
|
-
}
|
|
1666
|
-
const len = uintFromWord(bytes.slice(32, 64));
|
|
1667
|
-
if (len !== BigInt(expectedLength)) {
|
|
1668
|
-
throw new NodeRegistryError(`${label} must be ${expectedLength} bytes, got ${len}`);
|
|
1669
|
-
}
|
|
1670
|
-
const paddedLen = Math.ceil(expectedLength / 32) * 32;
|
|
1671
|
-
if (bytes.length < 64 + paddedLen) {
|
|
1672
|
-
throw new NodeRegistryError(`${label} body is truncated`);
|
|
1673
|
-
}
|
|
1674
|
-
return bytes.slice(64, 64 + expectedLength);
|
|
1675
|
-
}
|
|
1676
1607
|
|
|
1677
1608
|
// src/native-events.ts
|
|
1678
1609
|
var NATIVE_MARKET_EVENT_FAMILY = "market";
|
|
@@ -1814,6 +1745,40 @@ function parseBigint(value, label) {
|
|
|
1814
1745
|
return BigInt(value);
|
|
1815
1746
|
}
|
|
1816
1747
|
|
|
1748
|
+
// src/crypto/submission.ts
|
|
1749
|
+
function buildPlaintextSubmission(args) {
|
|
1750
|
+
const signed = args.backend.signEvmTx(args.tx);
|
|
1751
|
+
return {
|
|
1752
|
+
signedTxWireHex: `0x${signed.wireHex}`,
|
|
1753
|
+
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
1754
|
+
innerSighashHex: bytesToHex2(signed.sighash),
|
|
1755
|
+
innerWireBytes: signed.wireBytes.length
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
async function submitPlaintextTransaction(client, signedTxWireHex, expectedTxHashHex) {
|
|
1759
|
+
const returned = await client.call("mesh_submitTx", [signedTxWireHex]);
|
|
1760
|
+
const returnedBytes = hexToBytes2(returned, "mesh_submitTx tx hash");
|
|
1761
|
+
if (returnedBytes.length !== 32) {
|
|
1762
|
+
throw new Error(
|
|
1763
|
+
`mesh_submitTx tx hash must be 32 bytes, got ${returnedBytes.length}`
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1766
|
+
const expectedBytes = hexToBytes2(expectedTxHashHex, "expected tx hash");
|
|
1767
|
+
if (!bytesEqual(returnedBytes, expectedBytes)) {
|
|
1768
|
+
throw new Error(
|
|
1769
|
+
`mesh_submitTx returned tx hash ${bytesToHex2(returnedBytes)} but the locally computed canonical hash is ${bytesToHex2(expectedBytes)}`
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1772
|
+
return bytesToHex2(returnedBytes);
|
|
1773
|
+
}
|
|
1774
|
+
function bytesEqual(a, b) {
|
|
1775
|
+
if (a.length !== b.length) return false;
|
|
1776
|
+
for (let i = 0; i < a.length; i++) {
|
|
1777
|
+
if (a[i] !== b[i]) return false;
|
|
1778
|
+
}
|
|
1779
|
+
return true;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1817
1782
|
// src/crypto/bincode.ts
|
|
1818
1783
|
var BincodeWriter = class {
|
|
1819
1784
|
#chunks = [];
|
|
@@ -1873,782 +1838,115 @@ var BincodeWriter = class {
|
|
|
1873
1838
|
}
|
|
1874
1839
|
};
|
|
1875
1840
|
|
|
1876
|
-
// src/
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1841
|
+
// src/mrv.ts
|
|
1842
|
+
var MRV_FORMAT_VERSION = 1;
|
|
1843
|
+
var MRV_DEPLOY_PAYLOAD_VERSION = 1;
|
|
1844
|
+
var MRV_PROFILE_MONO_RV32IM_V1 = "mono_rv32im_v1";
|
|
1845
|
+
var MRV_MEMORY_PAGE_BYTES = 65536;
|
|
1846
|
+
var MRV_MAX_CODE_BYTES = 16 * 1024 * 1024;
|
|
1847
|
+
var MRV_MAX_DEBUG_BYTES = 16 * 1024 * 1024;
|
|
1848
|
+
var MRV_MAX_MEMORY_PAGES = 1024;
|
|
1849
|
+
var MRV_MAX_ABI_SYMBOLS = 1024;
|
|
1850
|
+
var MRV_MAX_STORAGE_NAMESPACE_BYTES = 64;
|
|
1851
|
+
var LYTH_DECIMALS = 18;
|
|
1852
|
+
var NATIVE_LYTH_DECIMALS = LYTH_DECIMALS;
|
|
1853
|
+
var LYTHOSHI_PER_LYTH = 1000000000000000000n;
|
|
1854
|
+
var MRV_TX_EXTENSION_KIND = 48;
|
|
1855
|
+
var MRV_TX_EXTENSION_V1 = 1;
|
|
1856
|
+
var MRV_CODE_HASH_DOMAIN = new TextEncoder().encode("MONO_MRV_CODE_V1");
|
|
1857
|
+
var MRV_CONTRACT_ADDRESS_DOMAIN = new TextEncoder().encode("mono:riscv:contract-address:v1");
|
|
1858
|
+
var MONO_SYSCALL_MODULE = "mono";
|
|
1859
|
+
var SYSCALLS = [
|
|
1860
|
+
[257, "storage_read"],
|
|
1861
|
+
[258, "storage_write"],
|
|
1862
|
+
[259, "storage_delete"],
|
|
1863
|
+
[513, "caller"],
|
|
1864
|
+
[514, "contract_address"],
|
|
1865
|
+
[515, "block_height"],
|
|
1866
|
+
[516, "block_hash"],
|
|
1867
|
+
[769, "call_contract"],
|
|
1868
|
+
[770, "emit_event"],
|
|
1869
|
+
[771, "transfer_native"],
|
|
1870
|
+
[1025, "verify_signature"],
|
|
1871
|
+
[1026, "hash"],
|
|
1872
|
+
[1281, "revert"]
|
|
1873
|
+
];
|
|
1874
|
+
var SYSCALL_NAME_BY_ID = new Map(SYSCALLS);
|
|
1875
|
+
var SYSCALL_ID_BY_NAME = new Map(SYSCALLS.map(([id, name]) => [name, id]));
|
|
1876
|
+
var MrvValidationError = class extends Error {
|
|
1877
|
+
constructor(message) {
|
|
1878
|
+
super(message);
|
|
1879
|
+
this.name = "MrvValidationError";
|
|
1910
1880
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
function
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1881
|
+
};
|
|
1882
|
+
var MRV_STRUCTURED_FEE_FIELDS = [
|
|
1883
|
+
"total_lythoshi",
|
|
1884
|
+
"cycles_used",
|
|
1885
|
+
"base_price_per_cycle_lythoshi",
|
|
1886
|
+
"state_io_units",
|
|
1887
|
+
"state_io_price_per_unit_lythoshi",
|
|
1888
|
+
"priority_tip_lythoshi"
|
|
1889
|
+
];
|
|
1890
|
+
function formatLyth(lythoshi, options = {}) {
|
|
1891
|
+
const amount = BigInt(normalizeDecimalLike("lythoshi", lythoshi));
|
|
1892
|
+
const whole = amount / LYTHOSHI_PER_LYTH;
|
|
1893
|
+
const fraction = amount % LYTHOSHI_PER_LYTH;
|
|
1894
|
+
let formatted = formatWholeWithCommas(whole);
|
|
1895
|
+
if (fraction !== 0n) {
|
|
1896
|
+
formatted += `.${fraction.toString().padStart(NATIVE_LYTH_DECIMALS, "0").replace(/0+$/, "")}`;
|
|
1897
|
+
}
|
|
1898
|
+
if (options.includeUnit !== false) {
|
|
1899
|
+
formatted += " LYTH";
|
|
1900
|
+
}
|
|
1901
|
+
return formatted;
|
|
1932
1902
|
}
|
|
1933
|
-
function
|
|
1934
|
-
|
|
1935
|
-
const bytes = normalizeBytes(value, "to");
|
|
1936
|
-
return expectBytes(bytes, 20, "to");
|
|
1903
|
+
function formatLythoshi(lythoshi, options = {}) {
|
|
1904
|
+
return formatLyth(lythoshi, options);
|
|
1937
1905
|
}
|
|
1938
|
-
function
|
|
1939
|
-
|
|
1940
|
-
|
|
1906
|
+
function parseLythToLythoshi(input) {
|
|
1907
|
+
const numeric = stripLythUnit(input);
|
|
1908
|
+
const parts = numeric.split(".");
|
|
1909
|
+
if (parts.length > 2) {
|
|
1910
|
+
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
1911
|
+
}
|
|
1912
|
+
const [wholeRaw, fractionRaw = ""] = parts;
|
|
1913
|
+
if (!isCanonicalWholeLyth(wholeRaw)) {
|
|
1914
|
+
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
1915
|
+
}
|
|
1916
|
+
if (numeric.includes(".") && fractionRaw.length === 0) {
|
|
1917
|
+
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
1918
|
+
}
|
|
1919
|
+
if (fractionRaw.length > NATIVE_LYTH_DECIMALS || !/^[0-9]*$/.test(fractionRaw)) {
|
|
1920
|
+
throw new MrvValidationError(`lyth amount supports at most ${NATIVE_LYTH_DECIMALS} decimal places`);
|
|
1921
|
+
}
|
|
1922
|
+
const whole = BigInt(wholeRaw.replaceAll(",", ""));
|
|
1923
|
+
const fraction = fractionRaw === "" ? 0n : BigInt(fractionRaw.padEnd(NATIVE_LYTH_DECIMALS, "0"));
|
|
1924
|
+
return whole * LYTHOSHI_PER_LYTH + fraction;
|
|
1941
1925
|
}
|
|
1942
|
-
function
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1926
|
+
function checkMrvFeeDisplayConformance(input) {
|
|
1927
|
+
const expectedTotalLythoshi = normalizeDecimalLike("expectedTotalLythoshi", input.expectedTotalLythoshi);
|
|
1928
|
+
const expectedDefaultFeeText = formatLyth(expectedTotalLythoshi);
|
|
1929
|
+
const failures = [];
|
|
1930
|
+
const amountCandidates = extractLythAmountCandidates(input.defaultFeeText);
|
|
1931
|
+
if (amountCandidates.length !== 1) {
|
|
1932
|
+
failures.push("defaultFeeText must contain exactly one LYTH-denominated fee amount");
|
|
1933
|
+
} else {
|
|
1934
|
+
const renderedCandidate = `${amountCandidates[0]} LYTH`;
|
|
1935
|
+
if (renderedCandidate !== expectedDefaultFeeText) {
|
|
1936
|
+
failures.push(`defaultFeeText fee must be ${expectedDefaultFeeText}`);
|
|
1947
1937
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1938
|
+
try {
|
|
1939
|
+
const parsed = parseLythToLythoshi(renderedCandidate);
|
|
1940
|
+
if (parsed.toString() !== expectedTotalLythoshi) {
|
|
1941
|
+
failures.push(`defaultFeeText fee must total ${expectedTotalLythoshi} lythoshi`);
|
|
1942
|
+
}
|
|
1943
|
+
} catch {
|
|
1944
|
+
failures.push(`defaultFeeText fee must be a canonical ${NATIVE_LYTH_DECIMALS}-decimal LYTH amount`);
|
|
1951
1945
|
}
|
|
1952
|
-
return { kind: ext.kind, body };
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
function encodeExtensionsForHash(extensions) {
|
|
1956
|
-
const chunks = [bigintToBeBytes(BigInt(extensions.length), 4, "extensions.length")];
|
|
1957
|
-
for (const ext of extensions) {
|
|
1958
|
-
chunks.push(
|
|
1959
|
-
Uint8Array.of(ext.kind),
|
|
1960
|
-
bigintToBeBytes(BigInt(ext.body.length), 4, "extension.body.length"),
|
|
1961
|
-
ext.body
|
|
1962
|
-
);
|
|
1963
1946
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
if (value < 0n || value >= 1n << 256n) throw new Error(`${label} out of u256 range`);
|
|
1968
|
-
const out = new Uint8Array(32);
|
|
1969
|
-
let v = value;
|
|
1970
|
-
for (let i = 31; i >= 0; i--) {
|
|
1971
|
-
out[i] = Number(v & 0xffn);
|
|
1972
|
-
v >>= 8n;
|
|
1973
|
-
}
|
|
1974
|
-
return out;
|
|
1975
|
-
}
|
|
1976
|
-
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
1977
|
-
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
1978
|
-
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
1979
|
-
w.bytes(raw);
|
|
1980
|
-
}
|
|
1981
|
-
function bincodeTypedExtensionInto(w, ext) {
|
|
1982
|
-
w.u8(ext.kind);
|
|
1983
|
-
w.bytes(ext.body);
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
// src/crypto/ml-dsa.ts
|
|
1987
|
-
var ML_DSA_65_SEED_LEN = 32;
|
|
1988
|
-
var ML_DSA_65_SIGNING_KEY_LEN = 4032;
|
|
1989
|
-
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
1990
|
-
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
1991
|
-
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
1992
|
-
var ENUM_VARIANT_INDEX_ML_DSA_65 = 3;
|
|
1993
|
-
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
1994
|
-
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
1995
|
-
var MlDsa65Backend = class _MlDsa65Backend {
|
|
1996
|
-
#secretKey;
|
|
1997
|
-
#publicKey;
|
|
1998
|
-
#addressBytes;
|
|
1999
|
-
#disposed = false;
|
|
2000
|
-
constructor(secretKey, publicKey) {
|
|
2001
|
-
this.#secretKey = expectBytes(secretKey, ML_DSA_65_SIGNING_KEY_LEN, "ML-DSA-65 secret key").slice();
|
|
2002
|
-
this.#publicKey = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key").slice();
|
|
2003
|
-
this.#addressBytes = mlDsa65AddressBytes(this.#publicKey);
|
|
2004
|
-
}
|
|
2005
|
-
static fromSeed(seed) {
|
|
2006
|
-
const kp = ml_dsa65.keygen(expectBytes(seed, ML_DSA_65_SEED_LEN, "ML-DSA-65 seed"));
|
|
2007
|
-
return new _MlDsa65Backend(kp.secretKey, kp.publicKey);
|
|
2008
|
-
}
|
|
2009
|
-
publicKey() {
|
|
2010
|
-
return this.#publicKey.slice();
|
|
2011
|
-
}
|
|
2012
|
-
addressBytes() {
|
|
2013
|
-
return this.#addressBytes.slice();
|
|
2014
|
-
}
|
|
2015
|
-
getAddress() {
|
|
2016
|
-
return bytesToHex2(this.#addressBytes);
|
|
2017
|
-
}
|
|
2018
|
-
sign(message) {
|
|
2019
|
-
if (this.#disposed) {
|
|
2020
|
-
throw new Error("MlDsa65Backend disposed");
|
|
2021
|
-
}
|
|
2022
|
-
return ml_dsa65.sign(message, this.#secretKey, { extraEntropy: false });
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* Best-effort deterministic wipe of the in-memory secret key. Zeroes the
|
|
2026
|
-
* SDK-held `#secretKey` copy and makes any subsequent `sign()` /
|
|
2027
|
-
* `signPrehash()` / `signEvmTx()` throw `"MlDsa65Backend disposed"` rather
|
|
2028
|
-
* than signing with a zeroed key. Idempotent. Public material
|
|
2029
|
-
* (`publicKey()` / `getAddress()` / `verify()`) stays usable.
|
|
2030
|
-
*
|
|
2031
|
-
* Defense-in-depth (S1-01): narrows the post-lock residency window of the
|
|
2032
|
-
* ML-DSA-65 secret in the JS heap. `@noble/post-quantum`'s internal
|
|
2033
|
-
* transient keygen/sign buffers are out of scope; the SDK-held copy is the
|
|
2034
|
-
* meaningful residency win.
|
|
2035
|
-
*/
|
|
2036
|
-
dispose() {
|
|
2037
|
-
this.#secretKey.fill(0);
|
|
2038
|
-
this.#disposed = true;
|
|
2039
|
-
}
|
|
2040
|
-
/** Alias for {@link dispose}. */
|
|
2041
|
-
zeroize() {
|
|
2042
|
-
this.dispose();
|
|
2043
|
-
}
|
|
2044
|
-
/** Whether {@link dispose} has been called (the secret key is wiped). */
|
|
2045
|
-
get disposed() {
|
|
2046
|
-
return this.#disposed;
|
|
2047
|
-
}
|
|
2048
|
-
signPrehash(digest) {
|
|
2049
|
-
return this.sign(expectBytes(digest, 32, "prehash"));
|
|
2050
|
-
}
|
|
2051
|
-
verify(message, signature) {
|
|
2052
|
-
return ml_dsa65.verify(
|
|
2053
|
-
expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature"),
|
|
2054
|
-
message,
|
|
2055
|
-
this.#publicKey
|
|
2056
|
-
);
|
|
2057
|
-
}
|
|
2058
|
-
signEvmTx(fields) {
|
|
2059
|
-
const txHashPreimage = encodeTransactionForHash(fields, 1);
|
|
2060
|
-
const sighash = keccak_256(txHashPreimage);
|
|
2061
|
-
const signature = this.sign(sighash);
|
|
2062
|
-
const wireBytes = bincodeSignedTransaction(fields, signature, this.#publicKey);
|
|
2063
|
-
const txHash = keccak_256(
|
|
2064
|
-
concatBytes2(
|
|
2065
|
-
encodeTransactionForHash(fields, 2),
|
|
2066
|
-
signature,
|
|
2067
|
-
this.#publicKey
|
|
2068
|
-
)
|
|
2069
|
-
);
|
|
2070
|
-
return {
|
|
2071
|
-
wireHex: bytesToHex2(wireBytes).slice(2),
|
|
2072
|
-
wireBytes,
|
|
2073
|
-
sighash,
|
|
2074
|
-
txHash
|
|
2075
|
-
};
|
|
2076
|
-
}
|
|
2077
|
-
};
|
|
2078
|
-
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
2079
|
-
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
2080
|
-
}
|
|
2081
|
-
function mlDsa65AddressBytes(publicKey) {
|
|
2082
|
-
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
2083
|
-
return blake3(concatBytes2(
|
|
2084
|
-
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
2085
|
-
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
2086
|
-
bytes
|
|
2087
|
-
)).slice(0, 20);
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
// src/crypto/envelope.ts
|
|
2091
|
-
new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
2092
|
-
var MempoolClass = {
|
|
2093
|
-
Transfer: 0,
|
|
2094
|
-
ContractCall: 1,
|
|
2095
|
-
CLOBOp: 3};
|
|
2096
|
-
function bincodeNonceAad(aad) {
|
|
2097
|
-
const w = new BincodeWriter();
|
|
2098
|
-
w.bytes(expectBytes(aad.sender, 20, "NonceAad.sender"));
|
|
2099
|
-
w.u64(aad.nonce);
|
|
2100
|
-
w.u64(aad.chainId);
|
|
2101
|
-
w.enumVariant(aad.class);
|
|
2102
|
-
w.u128(aad.maxFeePerGas);
|
|
2103
|
-
w.u128(aad.maxPriorityFeePerGas);
|
|
2104
|
-
w.u64(aad.gasLimit);
|
|
2105
|
-
return w.toBytes();
|
|
2106
|
-
}
|
|
2107
|
-
function bincodeDecryptHint(hint) {
|
|
2108
|
-
const w = new BincodeWriter();
|
|
2109
|
-
w.u64(hint.epoch);
|
|
2110
|
-
w.u16(hint.scheme);
|
|
2111
|
-
return w.toBytes();
|
|
2112
|
-
}
|
|
2113
|
-
function bincodeEncryptedEnvelope(env) {
|
|
2114
|
-
const w = new BincodeWriter();
|
|
2115
|
-
w.rawBytes(bincodeNonceAad(env.nonceAad));
|
|
2116
|
-
w.bytes(env.ciphertext);
|
|
2117
|
-
w.rawBytes(bincodeDecryptHint(env.decryptionHint));
|
|
2118
|
-
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"));
|
|
2119
|
-
bincodeMlDsa65OpaqueInto2(w, expectBytes(env.outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"));
|
|
2120
|
-
w.bytes(expectBytes(env.sender, 20, "sender"));
|
|
2121
|
-
return w.toBytes();
|
|
2122
|
-
}
|
|
2123
|
-
function outerSigDigest(nonceAad, ciphertext, decryptionHint, senderPubkey) {
|
|
2124
|
-
const aad = bincodeNonceAad(nonceAad);
|
|
2125
|
-
const hint = bincodeDecryptHint(decryptionHint);
|
|
2126
|
-
return keccak_256(concatBytes2(aad, ciphertext, hint, expectBytes(senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey")));
|
|
2127
|
-
}
|
|
2128
|
-
function bincodeMlDsa65OpaqueInto2(w, raw) {
|
|
2129
|
-
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
2130
|
-
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
2131
|
-
w.bytes(raw);
|
|
2132
|
-
}
|
|
2133
|
-
var SEAL_EK_LEN = 1184;
|
|
2134
|
-
var SEAL_KEY_LEN = 32;
|
|
2135
|
-
var SEAL_NONCE_LEN = 12;
|
|
2136
|
-
var SEAL_COMMIT_LEN = 32;
|
|
2137
|
-
var SEAL_SECRET_LEN = 32;
|
|
2138
|
-
var SEAL_SHARE_LEN = 1 + SEAL_SECRET_LEN;
|
|
2139
|
-
var CLUSTER_MLKEM_SHAMIR = 3;
|
|
2140
|
-
var COMMIT_DOMAIN = new TextEncoder().encode("lythiumseal/commit/v1");
|
|
2141
|
-
var KEK_DOMAIN = new TextEncoder().encode("lythiumseal/kek/v1");
|
|
2142
|
-
var NONCE_DOMAIN = new TextEncoder().encode("lythiumseal/nonce/v1");
|
|
2143
|
-
var BODY_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/body/v1");
|
|
2144
|
-
var SHARE_AAD_DOMAIN = new TextEncoder().encode("lythiumseal/share/v1");
|
|
2145
|
-
var ROSTER_DOMAIN = new TextEncoder().encode("lythiumseal/roster/v1");
|
|
2146
|
-
function cryptoRandomSource() {
|
|
2147
|
-
return {
|
|
2148
|
-
fillBytes(dest) {
|
|
2149
|
-
crypto.getRandomValues(dest);
|
|
2150
|
-
}
|
|
2151
|
-
};
|
|
2152
|
-
}
|
|
2153
|
-
function u32le(n) {
|
|
2154
|
-
const out = new Uint8Array(4);
|
|
2155
|
-
out[0] = n & 255;
|
|
2156
|
-
out[1] = n >>> 8 & 255;
|
|
2157
|
-
out[2] = n >>> 16 & 255;
|
|
2158
|
-
out[3] = n >>> 24 & 255;
|
|
2159
|
-
return out;
|
|
2160
|
-
}
|
|
2161
|
-
function u64le(n) {
|
|
2162
|
-
const out = new Uint8Array(8);
|
|
2163
|
-
let v = n;
|
|
2164
|
-
for (let i = 0; i < 8; i++) {
|
|
2165
|
-
out[i] = Number(v & 0xffn);
|
|
2166
|
-
v >>= 8n;
|
|
2167
|
-
}
|
|
2168
|
-
return out;
|
|
2169
|
-
}
|
|
2170
|
-
function framed(field2) {
|
|
2171
|
-
return concatBytes2(u32le(field2.length), field2);
|
|
2172
|
-
}
|
|
2173
|
-
function keyCommitment(key) {
|
|
2174
|
-
return shake256(concatBytes2(framed(COMMIT_DOMAIN), key), { dkLen: SEAL_COMMIT_LEN });
|
|
2175
|
-
}
|
|
2176
|
-
function deriveKek(sharedSecret, domain, clusterId, epoch, opIndex) {
|
|
2177
|
-
const input = concatBytes2(
|
|
2178
|
-
framed(KEK_DOMAIN),
|
|
2179
|
-
framed(sharedSecret),
|
|
2180
|
-
framed(domain),
|
|
2181
|
-
u32le(clusterId),
|
|
2182
|
-
u64le(epoch),
|
|
2183
|
-
Uint8Array.of(opIndex)
|
|
2184
|
-
);
|
|
2185
|
-
return shake256(input, { dkLen: SEAL_KEY_LEN });
|
|
2186
|
-
}
|
|
2187
|
-
function deriveNonce(domain, context) {
|
|
2188
|
-
const input = concatBytes2(framed(NONCE_DOMAIN), framed(domain), framed(context));
|
|
2189
|
-
return shake256(input, { dkLen: SEAL_NONCE_LEN });
|
|
2190
|
-
}
|
|
2191
|
-
function bodyAad(ctx, k, n) {
|
|
2192
|
-
return concatBytes2(
|
|
2193
|
-
BODY_AAD_DOMAIN,
|
|
2194
|
-
u32le(ctx.clusterId),
|
|
2195
|
-
u64le(ctx.epoch),
|
|
2196
|
-
Uint8Array.of(k),
|
|
2197
|
-
Uint8Array.of(n),
|
|
2198
|
-
ctx.rosterHash
|
|
2199
|
-
);
|
|
2200
|
-
}
|
|
2201
|
-
function shareAad(ctx, opIndex) {
|
|
2202
|
-
return concatBytes2(
|
|
2203
|
-
SHARE_AAD_DOMAIN,
|
|
2204
|
-
u32le(ctx.clusterId),
|
|
2205
|
-
u64le(ctx.epoch),
|
|
2206
|
-
Uint8Array.of(opIndex),
|
|
2207
|
-
ctx.rosterHash
|
|
2208
|
-
);
|
|
2209
|
-
}
|
|
2210
|
-
function aeadSeal(key, nonce, plaintext, aad) {
|
|
2211
|
-
const cipher = chacha20poly1305(key, nonce, aad);
|
|
2212
|
-
const ct = cipher.encrypt(plaintext);
|
|
2213
|
-
return { nonce, ct, commitment: keyCommitment(key) };
|
|
2214
|
-
}
|
|
2215
|
-
function gfMul(a, b) {
|
|
2216
|
-
let product = 0;
|
|
2217
|
-
let x = a & 255;
|
|
2218
|
-
let y = b & 255;
|
|
2219
|
-
for (let i = 0; i < 8; i++) {
|
|
2220
|
-
const mask = -(y & 1) & 255;
|
|
2221
|
-
product ^= x & mask;
|
|
2222
|
-
const high = -(x >> 7 & 1) & 255;
|
|
2223
|
-
x = x << 1 & 255;
|
|
2224
|
-
x ^= 27 & high;
|
|
2225
|
-
y >>= 1;
|
|
2226
|
-
}
|
|
2227
|
-
return product & 255;
|
|
2228
|
-
}
|
|
2229
|
-
function polyEval(coeffs, x) {
|
|
2230
|
-
let acc = 0;
|
|
2231
|
-
for (let i = coeffs.length - 1; i >= 0; i--) {
|
|
2232
|
-
acc = gfMul(acc, x) ^ coeffs[i];
|
|
2233
|
-
}
|
|
2234
|
-
return acc & 255;
|
|
2235
|
-
}
|
|
2236
|
-
function shamirSplit(secret, t, n, rng) {
|
|
2237
|
-
const byteCoeffs = [];
|
|
2238
|
-
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
2239
|
-
const c = new Uint8Array(t);
|
|
2240
|
-
c[0] = secret[j];
|
|
2241
|
-
if (t > 1) {
|
|
2242
|
-
const tail = new Uint8Array(t - 1);
|
|
2243
|
-
rng.fillBytes(tail);
|
|
2244
|
-
c.set(tail, 1);
|
|
2245
|
-
}
|
|
2246
|
-
byteCoeffs.push(c);
|
|
2247
|
-
}
|
|
2248
|
-
const shares = [];
|
|
2249
|
-
for (let k = 0; k < n; k++) {
|
|
2250
|
-
const x = k + 1 & 255;
|
|
2251
|
-
const value = new Uint8Array(SEAL_SECRET_LEN);
|
|
2252
|
-
for (let j = 0; j < SEAL_SECRET_LEN; j++) {
|
|
2253
|
-
value[j] = polyEval(byteCoeffs[j], x);
|
|
2254
|
-
}
|
|
2255
|
-
shares.push({ index: x, value });
|
|
2256
|
-
}
|
|
2257
|
-
return shares;
|
|
2258
|
-
}
|
|
2259
|
-
function shareToBytes(s) {
|
|
2260
|
-
const out = new Uint8Array(SEAL_SHARE_LEN);
|
|
2261
|
-
out[0] = s.index;
|
|
2262
|
-
out.set(s.value, 1);
|
|
2263
|
-
return out;
|
|
2264
|
-
}
|
|
2265
|
-
function sealRosterHash(keccak2562, clusterId, t, n, roster) {
|
|
2266
|
-
const chunks = [ROSTER_DOMAIN, u32le(clusterId), Uint8Array.of(t), Uint8Array.of(n)];
|
|
2267
|
-
for (const { operatorIndex, ek } of roster) {
|
|
2268
|
-
chunks.push(Uint8Array.of(operatorIndex), ek);
|
|
2269
|
-
}
|
|
2270
|
-
return keccak2562(concatBytes2(...chunks));
|
|
2271
|
-
}
|
|
2272
|
-
function encodeSealEnvelope(env) {
|
|
2273
|
-
const chunks = [];
|
|
2274
|
-
chunks.push(u32le(env.clusterId));
|
|
2275
|
-
chunks.push(u64le(env.epoch));
|
|
2276
|
-
chunks.push(expectBytes(env.rosterHash, 32, "rosterHash"));
|
|
2277
|
-
chunks.push(Uint8Array.of(env.t));
|
|
2278
|
-
chunks.push(Uint8Array.of(env.n));
|
|
2279
|
-
pushAeadBody(chunks, env.aeadBody);
|
|
2280
|
-
chunks.push(u64le(BigInt(env.recipients.length)));
|
|
2281
|
-
for (const r of env.recipients) {
|
|
2282
|
-
chunks.push(Uint8Array.of(r.operatorIndex));
|
|
2283
|
-
chunks.push(u64le(BigInt(r.kemCt.length)));
|
|
2284
|
-
chunks.push(r.kemCt);
|
|
2285
|
-
pushAeadBody(chunks, r.wrapped);
|
|
2286
|
-
}
|
|
2287
|
-
return concatBytes2(...chunks);
|
|
2288
|
-
}
|
|
2289
|
-
function pushAeadBody(chunks, body) {
|
|
2290
|
-
chunks.push(expectBytes(body.nonce, SEAL_NONCE_LEN, "aead nonce"));
|
|
2291
|
-
chunks.push(u64le(BigInt(body.ct.length)));
|
|
2292
|
-
chunks.push(body.ct);
|
|
2293
|
-
chunks.push(expectBytes(body.commitment, SEAL_COMMIT_LEN, "aead commitment"));
|
|
2294
|
-
}
|
|
2295
|
-
function sealToCluster(args) {
|
|
2296
|
-
const { plaintext, recipientEks, t, clusterId } = args;
|
|
2297
|
-
const epoch = args.epoch;
|
|
2298
|
-
const rosterHash = expectBytes(args.rosterHash, 32, "rosterHash");
|
|
2299
|
-
const rng = args.rng ?? cryptoRandomSource();
|
|
2300
|
-
const n = recipientEks.length;
|
|
2301
|
-
if (!Number.isInteger(t) || t < 1 || t > n || n < 1 || n > 255) {
|
|
2302
|
-
throw new Error(`invalid threshold/recipient count: t=${t} n=${n}`);
|
|
2303
|
-
}
|
|
2304
|
-
for (let i = 0; i < n; i++) {
|
|
2305
|
-
expectBytes(recipientEks[i], SEAL_EK_LEN, `recipientEks[${i}]`);
|
|
2306
|
-
}
|
|
2307
|
-
const ctx = { clusterId, epoch, rosterHash };
|
|
2308
|
-
const bodyKey = new Uint8Array(SEAL_KEY_LEN);
|
|
2309
|
-
rng.fillBytes(bodyKey);
|
|
2310
|
-
const aad = bodyAad(ctx, t, n);
|
|
2311
|
-
const bodyNonce = deriveNonce(new TextEncoder().encode("body"), aad);
|
|
2312
|
-
const aeadBody = aeadSeal(bodyKey, bodyNonce, plaintext, aad);
|
|
2313
|
-
const shares = shamirSplit(bodyKey, t, n, rng);
|
|
2314
|
-
const recipients = [];
|
|
2315
|
-
for (let i = 0; i < n; i++) {
|
|
2316
|
-
const opIndex = i + 1 & 255;
|
|
2317
|
-
const m = new Uint8Array(32);
|
|
2318
|
-
rng.fillBytes(m);
|
|
2319
|
-
const { cipherText: kemCt, sharedSecret } = ml_kem768.encapsulate(recipientEks[i], m);
|
|
2320
|
-
const kek = deriveKek(sharedSecret, rosterHash, clusterId, epoch, opIndex);
|
|
2321
|
-
const sAad = shareAad(ctx, opIndex);
|
|
2322
|
-
const wrapNonce = deriveNonce(new TextEncoder().encode("share"), sAad);
|
|
2323
|
-
const wrapped = aeadSeal(kek, wrapNonce, shareToBytes(shares[i]), sAad);
|
|
2324
|
-
recipients.push({ operatorIndex: opIndex, kemCt, wrapped });
|
|
2325
|
-
sharedSecret.fill(0);
|
|
2326
|
-
kek.fill(0);
|
|
2327
|
-
}
|
|
2328
|
-
bodyKey.fill(0);
|
|
2329
|
-
return {
|
|
2330
|
-
clusterId,
|
|
2331
|
-
epoch,
|
|
2332
|
-
rosterHash,
|
|
2333
|
-
t,
|
|
2334
|
-
n,
|
|
2335
|
-
aeadBody,
|
|
2336
|
-
recipients
|
|
2337
|
-
};
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
// src/crypto/seal.ts
|
|
2341
|
-
var CLUSTER_MLKEM_SHAMIR_ALGO = "cluster-mlkem768-shamir";
|
|
2342
|
-
function parseClusterSealKeys(source) {
|
|
2343
|
-
const n = source.roster.length;
|
|
2344
|
-
if (n === 0) {
|
|
2345
|
-
throw new Error("cluster seal roster is empty");
|
|
2346
|
-
}
|
|
2347
|
-
if (source.n !== n) {
|
|
2348
|
-
throw new Error(`cluster seal roster n=${source.n} disagrees with ${n} entries`);
|
|
2349
|
-
}
|
|
2350
|
-
if (!Number.isInteger(source.t) || source.t < 2 || source.t > n) {
|
|
2351
|
-
throw new Error(`cluster seal threshold t=${source.t} out of range 2..=${n}`);
|
|
2352
|
-
}
|
|
2353
|
-
const sorted = [...source.roster].sort((a, b) => a.operatorIndex - b.operatorIndex);
|
|
2354
|
-
const recipientEks = [];
|
|
2355
|
-
const hashInput = [];
|
|
2356
|
-
for (let i = 0; i < n; i++) {
|
|
2357
|
-
const entry = sorted[i];
|
|
2358
|
-
if (entry.operatorIndex !== i + 1) {
|
|
2359
|
-
throw new Error(
|
|
2360
|
-
`cluster seal roster operator indices must be 1..=${n}; got ${entry.operatorIndex} at slot ${i + 1}`
|
|
2361
|
-
);
|
|
2362
|
-
}
|
|
2363
|
-
const ek = expectBytes(hexToBytes2(entry.mlKemEk, `operator ${entry.operatorIndex} mlKemEk`), SEAL_EK_LEN, `operator ${entry.operatorIndex} ek`);
|
|
2364
|
-
recipientEks.push(ek);
|
|
2365
|
-
hashInput.push({ operatorIndex: entry.operatorIndex, ek });
|
|
2366
|
-
}
|
|
2367
|
-
const recomputed = sealRosterHash(keccak256, source.clusterId, source.t, n, hashInput);
|
|
2368
|
-
if (source.rosterHash !== void 0) {
|
|
2369
|
-
const supplied = expectBytes(hexToBytes2(source.rosterHash, "rosterHash"), 32, "rosterHash");
|
|
2370
|
-
if (!bytesEqual(supplied, recomputed)) {
|
|
2371
|
-
throw new Error(
|
|
2372
|
-
`cluster seal roster hash mismatch: source ${bytesToHex2(supplied)} != recomputed ${bytesToHex2(recomputed)} (the roster hash does not commit to this ek set)`
|
|
2373
|
-
);
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
return {
|
|
2377
|
-
algo: source.algo ?? CLUSTER_MLKEM_SHAMIR_ALGO,
|
|
2378
|
-
clusterId: source.clusterId,
|
|
2379
|
-
epoch: toBigInt(source.epoch),
|
|
2380
|
-
rosterHash: recomputed,
|
|
2381
|
-
t: source.t,
|
|
2382
|
-
n,
|
|
2383
|
-
recipientEks
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
async function sealTransaction(args) {
|
|
2387
|
-
const keys = args.clusterSealKeys;
|
|
2388
|
-
const senderPubkey = expectBytes(args.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey");
|
|
2389
|
-
const senderAddress = expectBytes(args.senderAddress, 20, "senderAddress");
|
|
2390
|
-
const env = sealToCluster({
|
|
2391
|
-
plaintext: args.signedTxBincode,
|
|
2392
|
-
recipientEks: keys.recipientEks,
|
|
2393
|
-
t: keys.t,
|
|
2394
|
-
clusterId: keys.clusterId,
|
|
2395
|
-
epoch: keys.epoch,
|
|
2396
|
-
rosterHash: keys.rosterHash,
|
|
2397
|
-
rng: args.rng
|
|
2398
|
-
});
|
|
2399
|
-
const ciphertext = encodeSealEnvelope(env);
|
|
2400
|
-
const decryptionHint = { epoch: keys.epoch, scheme: CLUSTER_MLKEM_SHAMIR };
|
|
2401
|
-
const digest = outerSigDigest(args.aad, ciphertext, decryptionHint, senderPubkey);
|
|
2402
|
-
const outerSignature = expectBytes(
|
|
2403
|
-
await args.signOuterDigest(digest),
|
|
2404
|
-
ML_DSA_65_SIGNATURE_LEN,
|
|
2405
|
-
"outerSignature"
|
|
2406
|
-
);
|
|
2407
|
-
const envelope = {
|
|
2408
|
-
nonceAad: args.aad,
|
|
2409
|
-
ciphertext,
|
|
2410
|
-
decryptionHint,
|
|
2411
|
-
senderPubkey,
|
|
2412
|
-
outerSignature,
|
|
2413
|
-
sender: senderAddress
|
|
2414
|
-
};
|
|
2415
|
-
const envelopeWireBytes = bincodeEncryptedEnvelope(envelope);
|
|
2416
|
-
return {
|
|
2417
|
-
envelopeWireHex: `0x${bytesToHex2(envelopeWireBytes).slice(2)}`,
|
|
2418
|
-
envelopeWireBytes,
|
|
2419
|
-
ciphertextBytes: ciphertext.length
|
|
2420
|
-
};
|
|
2421
|
-
}
|
|
2422
|
-
function keccak256(input) {
|
|
2423
|
-
return keccak_256(input);
|
|
2424
|
-
}
|
|
2425
|
-
function toBigInt(value) {
|
|
2426
|
-
if (typeof value === "bigint") return value;
|
|
2427
|
-
return BigInt(value);
|
|
2428
|
-
}
|
|
2429
|
-
function bytesEqual(a, b) {
|
|
2430
|
-
if (a.length !== b.length) return false;
|
|
2431
|
-
for (let i = 0; i < a.length; i++) {
|
|
2432
|
-
if (a[i] !== b[i]) return false;
|
|
2433
|
-
}
|
|
2434
|
-
return true;
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
// src/crypto/submission.ts
|
|
2438
|
-
async function fetchEncryptionKey(client) {
|
|
2439
|
-
const result = await client.call(
|
|
2440
|
-
"lyth_getEncryptionKey",
|
|
2441
|
-
[]
|
|
2442
|
-
);
|
|
2443
|
-
return {
|
|
2444
|
-
algo: result.algo ?? "ml-kem-768",
|
|
2445
|
-
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
2446
|
-
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "private submission requires cluster seal keys; pass clusterSealKeysSource or enable lyth_getClusterSealKeys";
|
|
2450
|
-
async function buildEncryptedSubmission(args) {
|
|
2451
|
-
const signed = args.backend.signEvmTx(args.tx);
|
|
2452
|
-
const clusterSealKeys = await resolveClusterSealKeys(args);
|
|
2453
|
-
const aad = nonceAadForTx(args.tx, args.backend.addressBytes(), args.class);
|
|
2454
|
-
const sealed = await sealTransaction({
|
|
2455
|
-
signedTxBincode: signed.wireBytes,
|
|
2456
|
-
clusterSealKeys,
|
|
2457
|
-
aad,
|
|
2458
|
-
senderAddress: args.backend.addressBytes(),
|
|
2459
|
-
senderPubkey: args.backend.publicKey(),
|
|
2460
|
-
signOuterDigest: (digest) => args.backend.signPrehash(digest)
|
|
2461
|
-
});
|
|
2462
|
-
return {
|
|
2463
|
-
envelopeWireHex: sealed.envelopeWireHex,
|
|
2464
|
-
innerSighashHex: bytesToHex2(signed.sighash),
|
|
2465
|
-
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
2466
|
-
innerWireBytes: signed.wireBytes.length
|
|
2467
|
-
};
|
|
2468
|
-
}
|
|
2469
|
-
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
2470
|
-
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
2471
|
-
}
|
|
2472
|
-
function buildPlaintextSubmission(args) {
|
|
2473
|
-
const signed = args.backend.signEvmTx(args.tx);
|
|
2474
|
-
return {
|
|
2475
|
-
signedTxWireHex: `0x${signed.wireHex}`,
|
|
2476
|
-
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
2477
|
-
innerSighashHex: bytesToHex2(signed.sighash),
|
|
2478
|
-
innerWireBytes: signed.wireBytes.length
|
|
2479
|
-
};
|
|
2480
|
-
}
|
|
2481
|
-
async function submitPlaintextTransaction(client, signedTxWireHex, expectedTxHashHex) {
|
|
2482
|
-
const returned = await client.call("mesh_submitTx", [signedTxWireHex]);
|
|
2483
|
-
const returnedBytes = hexToBytes2(returned, "mesh_submitTx tx hash");
|
|
2484
|
-
if (returnedBytes.length !== 32) {
|
|
2485
|
-
throw new Error(
|
|
2486
|
-
`mesh_submitTx tx hash must be 32 bytes, got ${returnedBytes.length}`
|
|
2487
|
-
);
|
|
2488
|
-
}
|
|
2489
|
-
const expectedBytes = hexToBytes2(expectedTxHashHex, "expected tx hash");
|
|
2490
|
-
if (!bytesEqual2(returnedBytes, expectedBytes)) {
|
|
2491
|
-
throw new Error(
|
|
2492
|
-
`mesh_submitTx returned tx hash ${bytesToHex2(returnedBytes)} but the locally computed canonical hash is ${bytesToHex2(expectedBytes)}`
|
|
2493
|
-
);
|
|
2494
|
-
}
|
|
2495
|
-
return bytesToHex2(returnedBytes);
|
|
2496
|
-
}
|
|
2497
|
-
function bytesEqual2(a, b) {
|
|
2498
|
-
if (a.length !== b.length) return false;
|
|
2499
|
-
for (let i = 0; i < a.length; i++) {
|
|
2500
|
-
if (a[i] !== b[i]) return false;
|
|
2501
|
-
}
|
|
2502
|
-
return true;
|
|
2503
|
-
}
|
|
2504
|
-
async function resolveClusterSealKeys(args) {
|
|
2505
|
-
if (args.clusterSealKeys !== void 0) return args.clusterSealKeys;
|
|
2506
|
-
if (args.clusterSealKeysSource !== void 0) {
|
|
2507
|
-
return parseClusterSealKeys(args.clusterSealKeysSource);
|
|
2508
|
-
}
|
|
2509
|
-
if (args.client === void 0) {
|
|
2510
|
-
throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
|
|
2511
|
-
}
|
|
2512
|
-
const clusterId = args.clusterId ?? 0;
|
|
2513
|
-
const result = await args.client.call(
|
|
2514
|
-
"lyth_getClusterSealKeys",
|
|
2515
|
-
[clusterId]
|
|
2516
|
-
);
|
|
2517
|
-
return parseClusterSealKeys({ ...result, clusterId: result.clusterId ?? clusterId });
|
|
2518
|
-
}
|
|
2519
|
-
function nonceAadForTx(tx, sender, mempoolClass) {
|
|
2520
|
-
return {
|
|
2521
|
-
sender,
|
|
2522
|
-
nonce: parseBigint(tx.nonce, "nonce"),
|
|
2523
|
-
chainId: parseBigint(tx.chainId, "chainId"),
|
|
2524
|
-
class: mempoolClass ?? inferMempoolClass(tx),
|
|
2525
|
-
maxFeePerGas: parseBigint(tx.maxFeePerGas, "maxFeePerGas"),
|
|
2526
|
-
maxPriorityFeePerGas: parseBigint(tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
2527
|
-
gasLimit: parseBigint(tx.gasLimit, "gasLimit")
|
|
2528
|
-
};
|
|
2529
|
-
}
|
|
2530
|
-
function inferMempoolClass(tx) {
|
|
2531
|
-
if (tx.to === null || hasInput(tx.input)) return MempoolClass.ContractCall;
|
|
2532
|
-
return MempoolClass.Transfer;
|
|
2533
|
-
}
|
|
2534
|
-
function hasInput(input) {
|
|
2535
|
-
if (input === void 0) return false;
|
|
2536
|
-
if (typeof input === "string") {
|
|
2537
|
-
const stripped = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
|
|
2538
|
-
return stripped.length > 0;
|
|
2539
|
-
}
|
|
2540
|
-
return input.length > 0;
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
// src/mrv.ts
|
|
2544
|
-
var MRV_FORMAT_VERSION = 1;
|
|
2545
|
-
var MRV_DEPLOY_PAYLOAD_VERSION = 1;
|
|
2546
|
-
var MRV_PROFILE_MONO_RV32IM_V1 = "mono_rv32im_v1";
|
|
2547
|
-
var MRV_MEMORY_PAGE_BYTES = 65536;
|
|
2548
|
-
var MRV_MAX_CODE_BYTES = 16 * 1024 * 1024;
|
|
2549
|
-
var MRV_MAX_DEBUG_BYTES = 16 * 1024 * 1024;
|
|
2550
|
-
var MRV_MAX_MEMORY_PAGES = 1024;
|
|
2551
|
-
var MRV_MAX_ABI_SYMBOLS = 1024;
|
|
2552
|
-
var MRV_MAX_STORAGE_NAMESPACE_BYTES = 64;
|
|
2553
|
-
var LYTH_DECIMALS = 18;
|
|
2554
|
-
var NATIVE_LYTH_DECIMALS = LYTH_DECIMALS;
|
|
2555
|
-
var LYTHOSHI_PER_LYTH = 1000000000000000000n;
|
|
2556
|
-
var MRV_TX_EXTENSION_KIND = 48;
|
|
2557
|
-
var MRV_TX_EXTENSION_V1 = 1;
|
|
2558
|
-
var MRV_CODE_HASH_DOMAIN = new TextEncoder().encode("MONO_MRV_CODE_V1");
|
|
2559
|
-
var MRV_CONTRACT_ADDRESS_DOMAIN = new TextEncoder().encode("mono:riscv:contract-address:v1");
|
|
2560
|
-
var MONO_SYSCALL_MODULE = "mono";
|
|
2561
|
-
var SYSCALLS = [
|
|
2562
|
-
[257, "storage_read"],
|
|
2563
|
-
[258, "storage_write"],
|
|
2564
|
-
[259, "storage_delete"],
|
|
2565
|
-
[513, "caller"],
|
|
2566
|
-
[514, "contract_address"],
|
|
2567
|
-
[515, "block_height"],
|
|
2568
|
-
[516, "block_hash"],
|
|
2569
|
-
[769, "call_contract"],
|
|
2570
|
-
[770, "emit_event"],
|
|
2571
|
-
[771, "transfer_native"],
|
|
2572
|
-
[1025, "verify_signature"],
|
|
2573
|
-
[1026, "hash"],
|
|
2574
|
-
[1281, "revert"]
|
|
2575
|
-
];
|
|
2576
|
-
var SYSCALL_NAME_BY_ID = new Map(SYSCALLS);
|
|
2577
|
-
var SYSCALL_ID_BY_NAME = new Map(SYSCALLS.map(([id, name]) => [name, id]));
|
|
2578
|
-
var MrvValidationError = class extends Error {
|
|
2579
|
-
constructor(message) {
|
|
2580
|
-
super(message);
|
|
2581
|
-
this.name = "MrvValidationError";
|
|
2582
|
-
}
|
|
2583
|
-
};
|
|
2584
|
-
var MRV_STRUCTURED_FEE_FIELDS = [
|
|
2585
|
-
"total_lythoshi",
|
|
2586
|
-
"cycles_used",
|
|
2587
|
-
"base_price_per_cycle_lythoshi",
|
|
2588
|
-
"state_io_units",
|
|
2589
|
-
"state_io_price_per_unit_lythoshi",
|
|
2590
|
-
"priority_tip_lythoshi"
|
|
2591
|
-
];
|
|
2592
|
-
function formatLyth(lythoshi, options = {}) {
|
|
2593
|
-
const amount = BigInt(normalizeDecimalLike("lythoshi", lythoshi));
|
|
2594
|
-
const whole = amount / LYTHOSHI_PER_LYTH;
|
|
2595
|
-
const fraction = amount % LYTHOSHI_PER_LYTH;
|
|
2596
|
-
let formatted = formatWholeWithCommas(whole);
|
|
2597
|
-
if (fraction !== 0n) {
|
|
2598
|
-
formatted += `.${fraction.toString().padStart(NATIVE_LYTH_DECIMALS, "0").replace(/0+$/, "")}`;
|
|
2599
|
-
}
|
|
2600
|
-
if (options.includeUnit !== false) {
|
|
2601
|
-
formatted += " LYTH";
|
|
2602
|
-
}
|
|
2603
|
-
return formatted;
|
|
2604
|
-
}
|
|
2605
|
-
function formatLythoshi(lythoshi, options = {}) {
|
|
2606
|
-
return formatLyth(lythoshi, options);
|
|
2607
|
-
}
|
|
2608
|
-
function parseLythToLythoshi(input) {
|
|
2609
|
-
const numeric = stripLythUnit(input);
|
|
2610
|
-
const parts = numeric.split(".");
|
|
2611
|
-
if (parts.length > 2) {
|
|
2612
|
-
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
2613
|
-
}
|
|
2614
|
-
const [wholeRaw, fractionRaw = ""] = parts;
|
|
2615
|
-
if (!isCanonicalWholeLyth(wholeRaw)) {
|
|
2616
|
-
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
2617
|
-
}
|
|
2618
|
-
if (numeric.includes(".") && fractionRaw.length === 0) {
|
|
2619
|
-
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
2620
|
-
}
|
|
2621
|
-
if (fractionRaw.length > NATIVE_LYTH_DECIMALS || !/^[0-9]*$/.test(fractionRaw)) {
|
|
2622
|
-
throw new MrvValidationError(`lyth amount supports at most ${NATIVE_LYTH_DECIMALS} decimal places`);
|
|
2623
|
-
}
|
|
2624
|
-
const whole = BigInt(wholeRaw.replaceAll(",", ""));
|
|
2625
|
-
const fraction = fractionRaw === "" ? 0n : BigInt(fractionRaw.padEnd(NATIVE_LYTH_DECIMALS, "0"));
|
|
2626
|
-
return whole * LYTHOSHI_PER_LYTH + fraction;
|
|
2627
|
-
}
|
|
2628
|
-
function checkMrvFeeDisplayConformance(input) {
|
|
2629
|
-
const expectedTotalLythoshi = normalizeDecimalLike("expectedTotalLythoshi", input.expectedTotalLythoshi);
|
|
2630
|
-
const expectedDefaultFeeText = formatLyth(expectedTotalLythoshi);
|
|
2631
|
-
const failures = [];
|
|
2632
|
-
const amountCandidates = extractLythAmountCandidates(input.defaultFeeText);
|
|
2633
|
-
if (amountCandidates.length !== 1) {
|
|
2634
|
-
failures.push("defaultFeeText must contain exactly one LYTH-denominated fee amount");
|
|
2635
|
-
} else {
|
|
2636
|
-
const renderedCandidate = `${amountCandidates[0]} LYTH`;
|
|
2637
|
-
if (renderedCandidate !== expectedDefaultFeeText) {
|
|
2638
|
-
failures.push(`defaultFeeText fee must be ${expectedDefaultFeeText}`);
|
|
2639
|
-
}
|
|
2640
|
-
try {
|
|
2641
|
-
const parsed = parseLythToLythoshi(renderedCandidate);
|
|
2642
|
-
if (parsed.toString() !== expectedTotalLythoshi) {
|
|
2643
|
-
failures.push(`defaultFeeText fee must total ${expectedTotalLythoshi} lythoshi`);
|
|
2644
|
-
}
|
|
2645
|
-
} catch {
|
|
2646
|
-
failures.push(`defaultFeeText fee must be a canonical ${NATIVE_LYTH_DECIMALS}-decimal LYTH amount`);
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
const defaultForbidden = firstForbiddenDefaultFeeTerm(input.defaultFeeText);
|
|
2650
|
-
if (defaultForbidden !== void 0) {
|
|
2651
|
-
failures.push(`defaultFeeText exposes detail-only fee term '${defaultForbidden}'`);
|
|
1947
|
+
const defaultForbidden = firstForbiddenDefaultFeeTerm(input.defaultFeeText);
|
|
1948
|
+
if (defaultForbidden !== void 0) {
|
|
1949
|
+
failures.push(`defaultFeeText exposes detail-only fee term '${defaultForbidden}'`);
|
|
2652
1950
|
}
|
|
2653
1951
|
for (const [index, detailText] of (input.detailTexts ?? []).entries()) {
|
|
2654
1952
|
const detailForbidden = firstForbiddenDetailFeeTerm(detailText);
|
|
@@ -3027,29 +2325,28 @@ function buildMrvNativeFeePreview(executionUnitLimit, maxExecutionFeeLythoshi, p
|
|
|
3027
2325
|
async function submitMrvDeployNativeTx(client, backend, artifactBytes, options) {
|
|
3028
2326
|
const plan = buildMrvDeployNativeTxPlan(artifactBytes, options);
|
|
3029
2327
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
3030
|
-
return
|
|
2328
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
3031
2329
|
}
|
|
3032
2330
|
async function submitMrvDeployPayloadNativeTx(client, backend, artifactBytes, options) {
|
|
3033
2331
|
const plan = buildMrvDeployPayloadNativeTxPlan(artifactBytes, options);
|
|
3034
2332
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
3035
|
-
return
|
|
2333
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
3036
2334
|
}
|
|
3037
2335
|
async function submitMrvCallNativeTx(client, backend, contractAddress, input, options) {
|
|
3038
2336
|
const plan = buildMrvCallNativeTxPlan(contractAddress, input, options);
|
|
3039
2337
|
assertMrvCallNativeSubmissionPlan(plan);
|
|
3040
|
-
return
|
|
3041
|
-
}
|
|
3042
|
-
async function
|
|
3043
|
-
const submission =
|
|
3044
|
-
backend,
|
|
3045
|
-
tx: plan.tx,
|
|
3046
|
-
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
3047
|
-
class: options.class
|
|
3048
|
-
});
|
|
2338
|
+
return submitMrvPlaintextNativeTx(client, backend, plan);
|
|
2339
|
+
}
|
|
2340
|
+
async function submitMrvPlaintextNativeTx(client, backend, plan) {
|
|
2341
|
+
const submission = buildPlaintextSubmission({ backend, tx: plan.tx });
|
|
3049
2342
|
return {
|
|
3050
2343
|
...plan,
|
|
3051
2344
|
...submission,
|
|
3052
|
-
txHash: await
|
|
2345
|
+
txHash: await submitPlaintextTransaction(
|
|
2346
|
+
client,
|
|
2347
|
+
submission.signedTxWireHex,
|
|
2348
|
+
submission.innerTxHashHex
|
|
2349
|
+
)
|
|
3053
2350
|
};
|
|
3054
2351
|
}
|
|
3055
2352
|
function assertMrvNativeSubmissionEnvelope(plan) {
|
|
@@ -3319,84 +2616,298 @@ function isCanonicalUnsignedDecimalString(value) {
|
|
|
3319
2616
|
} catch {
|
|
3320
2617
|
return false;
|
|
3321
2618
|
}
|
|
3322
|
-
}
|
|
3323
|
-
function normalizeDecimalLike(field2, value, defaultValue) {
|
|
3324
|
-
if (value === void 0) {
|
|
3325
|
-
if (defaultValue === void 0) throw new MrvValidationError(`${field2} is required`);
|
|
3326
|
-
return defaultValue;
|
|
2619
|
+
}
|
|
2620
|
+
function normalizeDecimalLike(field2, value, defaultValue) {
|
|
2621
|
+
if (value === void 0) {
|
|
2622
|
+
if (defaultValue === void 0) throw new MrvValidationError(`${field2} is required`);
|
|
2623
|
+
return defaultValue;
|
|
2624
|
+
}
|
|
2625
|
+
if (typeof value === "string") {
|
|
2626
|
+
validateDecimal(field2, value);
|
|
2627
|
+
return value;
|
|
2628
|
+
}
|
|
2629
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
2630
|
+
throw new MrvValidationError(`${field2} must be a safe unsigned integer`);
|
|
2631
|
+
}
|
|
2632
|
+
const out = BigInt(value);
|
|
2633
|
+
if (out < 0n) throw new MrvValidationError(`${field2} must be a canonical unsigned decimal string`);
|
|
2634
|
+
return out.toString();
|
|
2635
|
+
}
|
|
2636
|
+
function normalizeOptionalU64(field2, value) {
|
|
2637
|
+
return value === void 0 ? void 0 : normalizeU64(value, field2);
|
|
2638
|
+
}
|
|
2639
|
+
function validateDecimal(field2, value) {
|
|
2640
|
+
if (!/^(0|[1-9][0-9]*)$/.test(value)) {
|
|
2641
|
+
throw new MrvValidationError(`${field2} must be a canonical unsigned decimal string`);
|
|
2642
|
+
}
|
|
2643
|
+
try {
|
|
2644
|
+
BigInt(value);
|
|
2645
|
+
} catch {
|
|
2646
|
+
throw new MrvValidationError(`${field2} must be a canonical unsigned decimal string`);
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
function validateExecutionUnitLimit(field2, value) {
|
|
2650
|
+
if (value !== void 0 && BigInt(value) === 0n) {
|
|
2651
|
+
throw new MrvValidationError(`${field2} must be greater than zero`);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
function normalizeU64(value, field2) {
|
|
2655
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
2656
|
+
throw new MrvValidationError(`${field2} must be a safe unsigned integer`);
|
|
2657
|
+
}
|
|
2658
|
+
const out = BigInt(value);
|
|
2659
|
+
if (out < 0n || out > 0xffffffffffffffffn) {
|
|
2660
|
+
throw new MrvValidationError(`${field2} must fit in u64`);
|
|
2661
|
+
}
|
|
2662
|
+
return out;
|
|
2663
|
+
}
|
|
2664
|
+
function validateHexLength(field2, value, expected) {
|
|
2665
|
+
const bytes = hexToBytes3(value, field2);
|
|
2666
|
+
if (bytes.length !== expected) throw new MrvValidationError(`${field2} must be ${expected} bytes`);
|
|
2667
|
+
}
|
|
2668
|
+
function bytesFrom(value, field2) {
|
|
2669
|
+
if (typeof value === "string") return hexToBytes3(value, field2);
|
|
2670
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2671
|
+
}
|
|
2672
|
+
function hexToBytes3(value, field2) {
|
|
2673
|
+
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
2674
|
+
throw new MrvValidationError(`${field2} must be 0x-prefixed even-length hex`);
|
|
2675
|
+
}
|
|
2676
|
+
const out = new Uint8Array((value.length - 2) / 2);
|
|
2677
|
+
for (let i = 0; i < out.length; i++) {
|
|
2678
|
+
out[i] = Number.parseInt(value.slice(2 + i * 2, 4 + i * 2), 16);
|
|
2679
|
+
}
|
|
2680
|
+
return out;
|
|
2681
|
+
}
|
|
2682
|
+
function bytesToHex3(bytes) {
|
|
2683
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2684
|
+
}
|
|
2685
|
+
function concatBytes3(...parts) {
|
|
2686
|
+
const len = parts.reduce((sum, item) => sum + item.length, 0);
|
|
2687
|
+
const out = new Uint8Array(len);
|
|
2688
|
+
let offset = 0;
|
|
2689
|
+
for (const part of parts) {
|
|
2690
|
+
out.set(part, offset);
|
|
2691
|
+
offset += part.length;
|
|
2692
|
+
}
|
|
2693
|
+
return out;
|
|
2694
|
+
}
|
|
2695
|
+
function isIdentifier(value) {
|
|
2696
|
+
return /^[a-z][a-z0-9_]*$/.test(value);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
// src/crypto/tx.ts
|
|
2700
|
+
function encodeTransactionForHash(fields, tag) {
|
|
2701
|
+
const n = normalizeTxFields(fields);
|
|
2702
|
+
return concatBytes2(
|
|
2703
|
+
Uint8Array.of(tag),
|
|
2704
|
+
bigintToBeBytes(n.chainId, 8, "chainId"),
|
|
2705
|
+
bigintToBeBytes(n.nonce, 8, "nonce"),
|
|
2706
|
+
bigintToBeBytes(n.maxPriorityFeePerGas, 32, "maxPriorityFeePerGas"),
|
|
2707
|
+
bigintToBeBytes(n.maxFeePerGas, 32, "maxFeePerGas"),
|
|
2708
|
+
bigintToBeBytes(n.gasLimit, 8, "gasLimit"),
|
|
2709
|
+
n.to === null ? Uint8Array.of(0) : concatBytes2(Uint8Array.of(1), n.to),
|
|
2710
|
+
bigintToBeBytes(n.value, 32, "value"),
|
|
2711
|
+
bigintToBeBytes(BigInt(n.input.length), 4, "input.length"),
|
|
2712
|
+
n.input,
|
|
2713
|
+
new Uint8Array(4),
|
|
2714
|
+
// access_list length
|
|
2715
|
+
encodeExtensionsForHash(n.extensions)
|
|
2716
|
+
);
|
|
2717
|
+
}
|
|
2718
|
+
function bincodeSignedTransaction(fields, signature, publicKey) {
|
|
2719
|
+
const n = normalizeTxFields(fields);
|
|
2720
|
+
const sig = expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature");
|
|
2721
|
+
const pk = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
2722
|
+
const w = new BincodeWriter();
|
|
2723
|
+
w.u64(n.chainId);
|
|
2724
|
+
w.u64(n.nonce);
|
|
2725
|
+
w.bytes(uint256Be(n.maxPriorityFeePerGas, "maxPriorityFeePerGas"));
|
|
2726
|
+
w.bytes(uint256Be(n.maxFeePerGas, "maxFeePerGas"));
|
|
2727
|
+
w.u64(n.gasLimit);
|
|
2728
|
+
if (n.to === null) {
|
|
2729
|
+
w.u8(0);
|
|
2730
|
+
} else {
|
|
2731
|
+
w.u8(1);
|
|
2732
|
+
w.bytes(n.to);
|
|
2733
|
+
}
|
|
2734
|
+
w.bytes(uint256Be(n.value, "value"));
|
|
2735
|
+
w.bytes(n.input);
|
|
2736
|
+
w.u64(0n);
|
|
2737
|
+
w.u64(BigInt(n.extensions.length));
|
|
2738
|
+
for (const ext of n.extensions) bincodeTypedExtensionInto(w, ext);
|
|
2739
|
+
bincodeMlDsa65OpaqueInto(w, sig);
|
|
2740
|
+
bincodeMlDsa65OpaqueInto(w, pk);
|
|
2741
|
+
return w.toBytes();
|
|
2742
|
+
}
|
|
2743
|
+
function normalizeTxFields(fields) {
|
|
2744
|
+
return {
|
|
2745
|
+
chainId: parseBigint(fields.chainId, "chainId"),
|
|
2746
|
+
nonce: parseBigint(fields.nonce, "nonce"),
|
|
2747
|
+
maxPriorityFeePerGas: parseBigint(fields.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
2748
|
+
maxFeePerGas: parseBigint(fields.maxFeePerGas, "maxFeePerGas"),
|
|
2749
|
+
gasLimit: parseBigint(fields.gasLimit, "gasLimit"),
|
|
2750
|
+
to: normalizeTo(fields.to),
|
|
2751
|
+
value: parseBigint(fields.value, "value"),
|
|
2752
|
+
input: normalizeBytes(fields.input ?? new Uint8Array(0), "input"),
|
|
2753
|
+
extensions: normalizeExtensions(fields.extensions)
|
|
2754
|
+
};
|
|
2755
|
+
}
|
|
2756
|
+
function normalizeTo(value) {
|
|
2757
|
+
if (value === null) return null;
|
|
2758
|
+
const bytes = normalizeBytes(value, "to");
|
|
2759
|
+
return expectBytes(bytes, 20, "to");
|
|
2760
|
+
}
|
|
2761
|
+
function normalizeBytes(value, label) {
|
|
2762
|
+
if (typeof value === "string") return hexToBytes2(value, label);
|
|
2763
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2764
|
+
}
|
|
2765
|
+
function normalizeExtensions(value) {
|
|
2766
|
+
if (value === void 0) return [];
|
|
2767
|
+
return value.map((ext, index) => {
|
|
2768
|
+
if (!Number.isInteger(ext.kind) || ext.kind < 0 || ext.kind > 255) {
|
|
2769
|
+
throw new Error(`extensions[${index}].kind out of u8 range`);
|
|
2770
|
+
}
|
|
2771
|
+
const body = normalizeBytes("bodyHex" in ext ? ext.bodyHex : ext.body, `extensions[${index}].body`);
|
|
2772
|
+
if (body.length > 4294967295) {
|
|
2773
|
+
throw new Error(`extensions[${index}].body exceeds u32 length`);
|
|
2774
|
+
}
|
|
2775
|
+
return { kind: ext.kind, body };
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
function encodeExtensionsForHash(extensions) {
|
|
2779
|
+
const chunks = [bigintToBeBytes(BigInt(extensions.length), 4, "extensions.length")];
|
|
2780
|
+
for (const ext of extensions) {
|
|
2781
|
+
chunks.push(
|
|
2782
|
+
Uint8Array.of(ext.kind),
|
|
2783
|
+
bigintToBeBytes(BigInt(ext.body.length), 4, "extension.body.length"),
|
|
2784
|
+
ext.body
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2787
|
+
return concatBytes2(...chunks);
|
|
2788
|
+
}
|
|
2789
|
+
function uint256Be(value, label) {
|
|
2790
|
+
if (value < 0n || value >= 1n << 256n) throw new Error(`${label} out of u256 range`);
|
|
2791
|
+
const out = new Uint8Array(32);
|
|
2792
|
+
let v = value;
|
|
2793
|
+
for (let i = 31; i >= 0; i--) {
|
|
2794
|
+
out[i] = Number(v & 0xffn);
|
|
2795
|
+
v >>= 8n;
|
|
2796
|
+
}
|
|
2797
|
+
return out;
|
|
2798
|
+
}
|
|
2799
|
+
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
2800
|
+
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
2801
|
+
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
2802
|
+
w.bytes(raw);
|
|
2803
|
+
}
|
|
2804
|
+
function bincodeTypedExtensionInto(w, ext) {
|
|
2805
|
+
w.u8(ext.kind);
|
|
2806
|
+
w.bytes(ext.body);
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
// src/crypto/ml-dsa.ts
|
|
2810
|
+
var ML_DSA_65_SEED_LEN = 32;
|
|
2811
|
+
var ML_DSA_65_SIGNING_KEY_LEN = 4032;
|
|
2812
|
+
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
2813
|
+
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
2814
|
+
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
2815
|
+
var ENUM_VARIANT_INDEX_ML_DSA_65 = 3;
|
|
2816
|
+
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
2817
|
+
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
2818
|
+
var MlDsa65Backend = class _MlDsa65Backend {
|
|
2819
|
+
#secretKey;
|
|
2820
|
+
#publicKey;
|
|
2821
|
+
#addressBytes;
|
|
2822
|
+
#disposed = false;
|
|
2823
|
+
constructor(secretKey, publicKey) {
|
|
2824
|
+
this.#secretKey = expectBytes(secretKey, ML_DSA_65_SIGNING_KEY_LEN, "ML-DSA-65 secret key").slice();
|
|
2825
|
+
this.#publicKey = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key").slice();
|
|
2826
|
+
this.#addressBytes = mlDsa65AddressBytes(this.#publicKey);
|
|
2827
|
+
}
|
|
2828
|
+
static fromSeed(seed) {
|
|
2829
|
+
const kp = ml_dsa65.keygen(expectBytes(seed, ML_DSA_65_SEED_LEN, "ML-DSA-65 seed"));
|
|
2830
|
+
return new _MlDsa65Backend(kp.secretKey, kp.publicKey);
|
|
3327
2831
|
}
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
return value;
|
|
2832
|
+
publicKey() {
|
|
2833
|
+
return this.#publicKey.slice();
|
|
3331
2834
|
}
|
|
3332
|
-
|
|
3333
|
-
|
|
2835
|
+
addressBytes() {
|
|
2836
|
+
return this.#addressBytes.slice();
|
|
3334
2837
|
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
return out.toString();
|
|
3338
|
-
}
|
|
3339
|
-
function normalizeOptionalU64(field2, value) {
|
|
3340
|
-
return value === void 0 ? void 0 : normalizeU64(value, field2);
|
|
3341
|
-
}
|
|
3342
|
-
function validateDecimal(field2, value) {
|
|
3343
|
-
if (!/^(0|[1-9][0-9]*)$/.test(value)) {
|
|
3344
|
-
throw new MrvValidationError(`${field2} must be a canonical unsigned decimal string`);
|
|
2838
|
+
getAddress() {
|
|
2839
|
+
return bytesToHex2(this.#addressBytes);
|
|
3345
2840
|
}
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
2841
|
+
sign(message) {
|
|
2842
|
+
if (this.#disposed) {
|
|
2843
|
+
throw new Error("MlDsa65Backend disposed");
|
|
2844
|
+
}
|
|
2845
|
+
return ml_dsa65.sign(message, this.#secretKey, { extraEntropy: false });
|
|
3350
2846
|
}
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
2847
|
+
/**
|
|
2848
|
+
* Best-effort deterministic wipe of the in-memory secret key. Zeroes the
|
|
2849
|
+
* SDK-held `#secretKey` copy and makes any subsequent `sign()` /
|
|
2850
|
+
* `signPrehash()` / `signEvmTx()` throw `"MlDsa65Backend disposed"` rather
|
|
2851
|
+
* than signing with a zeroed key. Idempotent. Public material
|
|
2852
|
+
* (`publicKey()` / `getAddress()` / `verify()`) stays usable.
|
|
2853
|
+
*
|
|
2854
|
+
* Defense-in-depth (S1-01): narrows the post-lock residency window of the
|
|
2855
|
+
* ML-DSA-65 secret in the JS heap. `@noble/post-quantum`'s internal
|
|
2856
|
+
* transient keygen/sign buffers are out of scope; the SDK-held copy is the
|
|
2857
|
+
* meaningful residency win.
|
|
2858
|
+
*/
|
|
2859
|
+
dispose() {
|
|
2860
|
+
this.#secretKey.fill(0);
|
|
2861
|
+
this.#disposed = true;
|
|
3355
2862
|
}
|
|
3356
|
-
}
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
throw new MrvValidationError(`${field2} must be a safe unsigned integer`);
|
|
2863
|
+
/** Alias for {@link dispose}. */
|
|
2864
|
+
zeroize() {
|
|
2865
|
+
this.dispose();
|
|
3360
2866
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
2867
|
+
/** Whether {@link dispose} has been called (the secret key is wiped). */
|
|
2868
|
+
get disposed() {
|
|
2869
|
+
return this.#disposed;
|
|
3364
2870
|
}
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
function validateHexLength(field2, value, expected) {
|
|
3368
|
-
const bytes = hexToBytes3(value, field2);
|
|
3369
|
-
if (bytes.length !== expected) throw new MrvValidationError(`${field2} must be ${expected} bytes`);
|
|
3370
|
-
}
|
|
3371
|
-
function bytesFrom(value, field2) {
|
|
3372
|
-
if (typeof value === "string") return hexToBytes3(value, field2);
|
|
3373
|
-
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
3374
|
-
}
|
|
3375
|
-
function hexToBytes3(value, field2) {
|
|
3376
|
-
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
3377
|
-
throw new MrvValidationError(`${field2} must be 0x-prefixed even-length hex`);
|
|
2871
|
+
signPrehash(digest) {
|
|
2872
|
+
return this.sign(expectBytes(digest, 32, "prehash"));
|
|
3378
2873
|
}
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
2874
|
+
verify(message, signature) {
|
|
2875
|
+
return ml_dsa65.verify(
|
|
2876
|
+
expectBytes(signature, ML_DSA_65_SIGNATURE_LEN, "ML-DSA-65 signature"),
|
|
2877
|
+
message,
|
|
2878
|
+
this.#publicKey
|
|
2879
|
+
);
|
|
3382
2880
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
2881
|
+
signEvmTx(fields) {
|
|
2882
|
+
const txHashPreimage = encodeTransactionForHash(fields, 1);
|
|
2883
|
+
const sighash = keccak_256(txHashPreimage);
|
|
2884
|
+
const signature = this.sign(sighash);
|
|
2885
|
+
const wireBytes = bincodeSignedTransaction(fields, signature, this.#publicKey);
|
|
2886
|
+
const txHash = keccak_256(
|
|
2887
|
+
concatBytes2(
|
|
2888
|
+
encodeTransactionForHash(fields, 2),
|
|
2889
|
+
signature,
|
|
2890
|
+
this.#publicKey
|
|
2891
|
+
)
|
|
2892
|
+
);
|
|
2893
|
+
return {
|
|
2894
|
+
wireHex: bytesToHex2(wireBytes).slice(2),
|
|
2895
|
+
wireBytes,
|
|
2896
|
+
sighash,
|
|
2897
|
+
txHash
|
|
2898
|
+
};
|
|
3395
2899
|
}
|
|
3396
|
-
|
|
2900
|
+
};
|
|
2901
|
+
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
2902
|
+
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
3397
2903
|
}
|
|
3398
|
-
function
|
|
3399
|
-
|
|
2904
|
+
function mlDsa65AddressBytes(publicKey) {
|
|
2905
|
+
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
2906
|
+
return blake3(concatBytes2(
|
|
2907
|
+
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
2908
|
+
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
2909
|
+
bytes
|
|
2910
|
+
)).slice(0, 20);
|
|
3400
2911
|
}
|
|
3401
2912
|
|
|
3402
2913
|
// src/registry.ts
|
|
@@ -3406,8 +2917,8 @@ var TESTNET_69420 = {
|
|
|
3406
2917
|
network: "testnet-69420",
|
|
3407
2918
|
display_name: "Monolythium Testnet",
|
|
3408
2919
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
3409
|
-
genesis_hash: "
|
|
3410
|
-
binary_sha: "
|
|
2920
|
+
genesis_hash: "0xb52b59d667a0ad97c531607b840b7082547ba3151aa11a819eb6916b080b1ca9",
|
|
2921
|
+
binary_sha: "6f33aa30",
|
|
3411
2922
|
rpc: [
|
|
3412
2923
|
{
|
|
3413
2924
|
url: "http://178.105.12.9:8545",
|
|
@@ -4987,14 +4498,6 @@ var RpcClient = class _RpcClient {
|
|
|
4987
4498
|
async lythSubmitPendingChange(envelope) {
|
|
4988
4499
|
return this.call("lyth_submitPendingChange", [envelope]);
|
|
4989
4500
|
}
|
|
4990
|
-
/** `lyth_submitEncrypted` — submit a bincode-encoded encrypted envelope hex. */
|
|
4991
|
-
async lythSubmitEncrypted(envelopeHex) {
|
|
4992
|
-
return this.call("lyth_submitEncrypted", [envelopeHex]);
|
|
4993
|
-
}
|
|
4994
|
-
/** `lyth_getEncryptionKey` — cluster ML-KEM encapsulation key. */
|
|
4995
|
-
async lythGetEncryptionKey() {
|
|
4996
|
-
return this.call("lyth_getEncryptionKey", []);
|
|
4997
|
-
}
|
|
4998
4501
|
/** `lyth_syncStatus` — DAG-sync driver snapshot. */
|
|
4999
4502
|
async lythSyncStatus() {
|
|
5000
4503
|
const v = await this.call("lyth_syncStatus", []);
|
|
@@ -8151,7 +7654,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
8151
7654
|
}
|
|
8152
7655
|
const actualRoot = computeNoEvmReceiptsRoot(receipts);
|
|
8153
7656
|
const expectedRoot = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
8154
|
-
if (!
|
|
7657
|
+
if (!bytesEqual2(expectedRoot, decodeHash(actualRoot, "computedReceiptsRoot"))) {
|
|
8155
7658
|
throw new NoEvmReceiptProofError(
|
|
8156
7659
|
"receipts_root_mismatch",
|
|
8157
7660
|
`receiptsRoot mismatch: expected ${proof.receiptsRoot}, computed ${actualRoot}`
|
|
@@ -8159,7 +7662,7 @@ function verifyBoundedReceiptProof(proof) {
|
|
|
8159
7662
|
}
|
|
8160
7663
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
8161
7664
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
8162
|
-
if (!
|
|
7665
|
+
if (!bytesEqual2(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
8163
7666
|
throw new NoEvmReceiptProofError(
|
|
8164
7667
|
"target_receipt_hash_mismatch",
|
|
8165
7668
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -8216,7 +7719,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8216
7719
|
const targetReceipt = decodeHexBytes(targetReceiptBytes, "targetReceiptBytes");
|
|
8217
7720
|
const actualTargetHash = computeNoEvmTargetReceiptHash(targetReceipt);
|
|
8218
7721
|
const expectedTargetHash = decodeHash(proof.targetReceiptHash, "targetReceiptHash");
|
|
8219
|
-
if (!
|
|
7722
|
+
if (!bytesEqual2(expectedTargetHash, decodeHash(actualTargetHash, "computedTargetReceiptHash"))) {
|
|
8220
7723
|
throw new NoEvmReceiptProofError(
|
|
8221
7724
|
"target_receipt_hash_mismatch",
|
|
8222
7725
|
`targetReceiptHash mismatch: expected ${proof.targetReceiptHash}, computed ${actualTargetHash}`
|
|
@@ -8227,7 +7730,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8227
7730
|
compactProof.leafHash,
|
|
8228
7731
|
"compactInclusionProof.leafHash"
|
|
8229
7732
|
);
|
|
8230
|
-
if (!
|
|
7733
|
+
if (!bytesEqual2(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
8231
7734
|
throw new NoEvmReceiptProofError(
|
|
8232
7735
|
"compact_leaf_hash_mismatch",
|
|
8233
7736
|
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
@@ -8237,7 +7740,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8237
7740
|
}
|
|
8238
7741
|
const compactRootBytes = decodeHash(compactProof.root, "compactInclusionProof.root");
|
|
8239
7742
|
const receiptsRootBytes = decodeHash(proof.receiptsRoot, "receiptsRoot");
|
|
8240
|
-
if (!
|
|
7743
|
+
if (!bytesEqual2(receiptsRootBytes, compactRootBytes)) {
|
|
8241
7744
|
throw new NoEvmReceiptProofError(
|
|
8242
7745
|
"compact_root_mismatch",
|
|
8243
7746
|
`receiptsRoot must equal compactInclusionProof.root: receiptsRoot ${proof.receiptsRoot}, compact root ${compactProof.root}`
|
|
@@ -8260,7 +7763,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
8260
7763
|
siblingHashes,
|
|
8261
7764
|
pathSides
|
|
8262
7765
|
);
|
|
8263
|
-
if (!
|
|
7766
|
+
if (!bytesEqual2(actualRootBytes, compactRootBytes)) {
|
|
8264
7767
|
throw new NoEvmReceiptProofError(
|
|
8265
7768
|
"compact_path_mismatch",
|
|
8266
7769
|
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
@@ -8414,7 +7917,7 @@ function validateCoveringSnapshotObject(snapshot, archiveContentHash, proofBlock
|
|
|
8414
7917
|
"archiveProof.coveringSnapshot.checkpointTo must match blockHeight"
|
|
8415
7918
|
);
|
|
8416
7919
|
}
|
|
8417
|
-
if (!
|
|
7920
|
+
if (!bytesEqual2(checkpointContentHash, archiveContentHash)) {
|
|
8418
7921
|
throw new NoEvmReceiptProofError(
|
|
8419
7922
|
"invalid_proof_shape",
|
|
8420
7923
|
"archiveProof.coveringSnapshot.checkpointContentHash must match archiveProof.contentHash"
|
|
@@ -8613,7 +8116,7 @@ function validateFinalityBlockReference(blockReference, round, proofBlockHash) {
|
|
|
8613
8116
|
);
|
|
8614
8117
|
if (proofBlockHash !== void 0) {
|
|
8615
8118
|
const blockHash = decodeHash(proofBlockHash, "blockHash");
|
|
8616
|
-
if (!
|
|
8119
|
+
if (!bytesEqual2(digest, blockHash)) {
|
|
8617
8120
|
throw new NoEvmReceiptProofError(
|
|
8618
8121
|
"invalid_proof_shape",
|
|
8619
8122
|
"finalityEvidence.blockReference.digest must match blockHash"
|
|
@@ -8963,7 +8466,7 @@ function assertHashBytes(value, field2) {
|
|
|
8963
8466
|
function isRecord3(value) {
|
|
8964
8467
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8965
8468
|
}
|
|
8966
|
-
function
|
|
8469
|
+
function bytesEqual2(a, b) {
|
|
8967
8470
|
if (a.length !== b.length) return false;
|
|
8968
8471
|
let diff = 0;
|
|
8969
8472
|
for (let index = 0; index < a.length; index++) {
|
|
@@ -8978,6 +8481,191 @@ function bytesToHex6(bytes) {
|
|
|
8978
8481
|
}
|
|
8979
8482
|
return out;
|
|
8980
8483
|
}
|
|
8484
|
+
var TREE_TAG_LEAF = 0;
|
|
8485
|
+
var TREE_TAG_INTERNAL = 1;
|
|
8486
|
+
var TREE_TERMINATOR = new Uint8Array(32);
|
|
8487
|
+
var HASH_BYTE_LENGTH2 = 32;
|
|
8488
|
+
var PROOF_KIND_BINARY = "binary";
|
|
8489
|
+
var ProofVerifyError = class extends Error {
|
|
8490
|
+
constructor(code, message) {
|
|
8491
|
+
super(message);
|
|
8492
|
+
this.code = code;
|
|
8493
|
+
this.name = "ProofVerifyError";
|
|
8494
|
+
}
|
|
8495
|
+
code;
|
|
8496
|
+
};
|
|
8497
|
+
function hashValue(data) {
|
|
8498
|
+
return blake3(data);
|
|
8499
|
+
}
|
|
8500
|
+
function hashLeaf(path, valueHash) {
|
|
8501
|
+
const buf = new Uint8Array(1 + 32 + 32);
|
|
8502
|
+
buf[0] = TREE_TAG_LEAF;
|
|
8503
|
+
buf.set(path, 1);
|
|
8504
|
+
buf.set(valueHash, 33);
|
|
8505
|
+
return blake3(buf);
|
|
8506
|
+
}
|
|
8507
|
+
function compress(left, right) {
|
|
8508
|
+
if (isTerminator(left) && isTerminator(right)) {
|
|
8509
|
+
return TREE_TERMINATOR;
|
|
8510
|
+
}
|
|
8511
|
+
const buf = new Uint8Array(1 + 32 + 32);
|
|
8512
|
+
buf[0] = TREE_TAG_INTERNAL;
|
|
8513
|
+
buf.set(left, 1);
|
|
8514
|
+
buf.set(right, 33);
|
|
8515
|
+
return blake3(buf);
|
|
8516
|
+
}
|
|
8517
|
+
function isTerminator(hash) {
|
|
8518
|
+
for (let i = 0; i < hash.length; i++) {
|
|
8519
|
+
if (hash[i] !== 0) return false;
|
|
8520
|
+
}
|
|
8521
|
+
return true;
|
|
8522
|
+
}
|
|
8523
|
+
function pathBit(path, depth) {
|
|
8524
|
+
const byte = path[depth >>> 3];
|
|
8525
|
+
return byte >>> 7 - (depth & 7) & 1;
|
|
8526
|
+
}
|
|
8527
|
+
function foldToRoot(target, current, siblings) {
|
|
8528
|
+
const depth = siblings.length;
|
|
8529
|
+
let node = current;
|
|
8530
|
+
for (let i = 0; i < depth; i++) {
|
|
8531
|
+
const level = depth - 1 - i;
|
|
8532
|
+
const sibling = siblings[i];
|
|
8533
|
+
node = pathBit(target, level) === 0 ? compress(node, sibling) : compress(sibling, node);
|
|
8534
|
+
}
|
|
8535
|
+
return node;
|
|
8536
|
+
}
|
|
8537
|
+
function bytesEqual3(a, b) {
|
|
8538
|
+
if (a.length !== b.length) return false;
|
|
8539
|
+
for (let i = 0; i < a.length; i++) {
|
|
8540
|
+
if (a[i] !== b[i]) return false;
|
|
8541
|
+
}
|
|
8542
|
+
return true;
|
|
8543
|
+
}
|
|
8544
|
+
function decodeHash2(value, field2) {
|
|
8545
|
+
let bytes;
|
|
8546
|
+
try {
|
|
8547
|
+
bytes = hexToBytes2(value, field2);
|
|
8548
|
+
} catch (cause) {
|
|
8549
|
+
throw new ProofVerifyError("invalid_hex", `${field2} is not valid hex: ${String(cause)}`);
|
|
8550
|
+
}
|
|
8551
|
+
if (bytes.length !== HASH_BYTE_LENGTH2) {
|
|
8552
|
+
throw new ProofVerifyError(
|
|
8553
|
+
"invalid_hash_length",
|
|
8554
|
+
`${field2} must be ${HASH_BYTE_LENGTH2} bytes, got ${bytes.length}`
|
|
8555
|
+
);
|
|
8556
|
+
}
|
|
8557
|
+
return bytes;
|
|
8558
|
+
}
|
|
8559
|
+
function decodeSiblings(siblings) {
|
|
8560
|
+
return siblings.map((sib, index) => decodeHash2(sib, `siblings[${index}]`));
|
|
8561
|
+
}
|
|
8562
|
+
function assertBinaryKind(proofKind) {
|
|
8563
|
+
if (proofKind !== PROOF_KIND_BINARY) {
|
|
8564
|
+
throw new ProofVerifyError(
|
|
8565
|
+
"unsupported_proof_kind",
|
|
8566
|
+
`unsupported proofKind: ${proofKind} (expected ${PROOF_KIND_BINARY})`
|
|
8567
|
+
);
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
var ProofVerifier = class {
|
|
8571
|
+
/**
|
|
8572
|
+
* Verify a {@link ProofEnvelope} inclusion proof against `stateRoot`.
|
|
8573
|
+
*
|
|
8574
|
+
* @returns `true` when the proof binds `(key, value)` to `stateRoot`.
|
|
8575
|
+
*/
|
|
8576
|
+
verifyInclusion(stateRoot, proof) {
|
|
8577
|
+
assertBinaryKind(proof.proofKind);
|
|
8578
|
+
const root = toHashBytes(stateRoot, "stateRoot");
|
|
8579
|
+
const key = decodeHex(proof.key, "proof.key");
|
|
8580
|
+
const value = decodeHex(proof.value, "proof.value");
|
|
8581
|
+
const siblings = decodeSiblings(proof.siblings);
|
|
8582
|
+
const target = hashValue(key);
|
|
8583
|
+
const leaf = hashLeaf(target, hashValue(value));
|
|
8584
|
+
return bytesEqual3(foldToRoot(target, leaf, siblings), root);
|
|
8585
|
+
}
|
|
8586
|
+
/**
|
|
8587
|
+
* Verify a {@link ProofEnvelope} inclusion proof, throwing a
|
|
8588
|
+
* {@link ProofVerifyError} on failure (the loud variant for wallets).
|
|
8589
|
+
*/
|
|
8590
|
+
assertInclusion(stateRoot, proof) {
|
|
8591
|
+
if (!this.verifyInclusion(stateRoot, proof)) {
|
|
8592
|
+
throw new ProofVerifyError(
|
|
8593
|
+
"proof_verify_failed",
|
|
8594
|
+
`inclusion proof for key ${proof.key} does not verify against the state root`
|
|
8595
|
+
);
|
|
8596
|
+
}
|
|
8597
|
+
}
|
|
8598
|
+
/**
|
|
8599
|
+
* Verify a {@link NonInclusionProofEnvelope} against `stateRoot`.
|
|
8600
|
+
*
|
|
8601
|
+
* Returns `false` for a `found` endpoint (that is an inclusion, not
|
|
8602
|
+
* absence) or an `otherLeaf` whose path equals the queried key. Mirrors
|
|
8603
|
+
* `protocore_state::verify_binary_non_inclusion`.
|
|
8604
|
+
*/
|
|
8605
|
+
verifyNonInclusion(stateRoot, proof) {
|
|
8606
|
+
assertBinaryKind(proof.proofKind);
|
|
8607
|
+
const root = toHashBytes(stateRoot, "stateRoot");
|
|
8608
|
+
const key = decodeHex(proof.key, "proof.key");
|
|
8609
|
+
const siblings = decodeSiblings(proof.siblings);
|
|
8610
|
+
const target = hashValue(key);
|
|
8611
|
+
let endpointHash;
|
|
8612
|
+
switch (proof.endpoint.kind) {
|
|
8613
|
+
case "found":
|
|
8614
|
+
return false;
|
|
8615
|
+
case "terminator":
|
|
8616
|
+
endpointHash = TREE_TERMINATOR;
|
|
8617
|
+
break;
|
|
8618
|
+
case "otherLeaf": {
|
|
8619
|
+
const path = decodeHash2(proof.endpoint.path, "endpoint.path");
|
|
8620
|
+
if (bytesEqual3(path, target)) return false;
|
|
8621
|
+
endpointHash = hashLeaf(path, decodeHash2(proof.endpoint.valueHash, "endpoint.valueHash"));
|
|
8622
|
+
break;
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
return bytesEqual3(foldToRoot(target, endpointHash, siblings), root);
|
|
8626
|
+
}
|
|
8627
|
+
/**
|
|
8628
|
+
* Verify a non-inclusion proof, throwing a {@link ProofVerifyError} on
|
|
8629
|
+
* failure.
|
|
8630
|
+
*/
|
|
8631
|
+
assertNonInclusion(stateRoot, proof) {
|
|
8632
|
+
if (!this.verifyNonInclusion(stateRoot, proof)) {
|
|
8633
|
+
throw new ProofVerifyError(
|
|
8634
|
+
"non_inclusion_verify_failed",
|
|
8635
|
+
`non-inclusion proof for key ${proof.key} does not verify against the state root`
|
|
8636
|
+
);
|
|
8637
|
+
}
|
|
8638
|
+
}
|
|
8639
|
+
};
|
|
8640
|
+
var proofVerifier = new ProofVerifier();
|
|
8641
|
+
function toHashBytes(value, field2) {
|
|
8642
|
+
if (typeof value === "string") return decodeHash2(value, field2);
|
|
8643
|
+
return expectBytes(value, HASH_BYTE_LENGTH2, field2);
|
|
8644
|
+
}
|
|
8645
|
+
function decodeHex(value, field2) {
|
|
8646
|
+
try {
|
|
8647
|
+
return hexToBytes2(value, field2);
|
|
8648
|
+
} catch (cause) {
|
|
8649
|
+
throw new ProofVerifyError("invalid_hex", `${field2} is not valid hex: ${String(cause)}`);
|
|
8650
|
+
}
|
|
8651
|
+
}
|
|
8652
|
+
function asBinaryProofEnvelope(proof) {
|
|
8653
|
+
if (proof == null || typeof proof !== "object") return null;
|
|
8654
|
+
const obj = proof;
|
|
8655
|
+
if (obj.proofKind !== PROOF_KIND_BINARY) return null;
|
|
8656
|
+
if (typeof obj.key !== "string" || typeof obj.value !== "string" || !Array.isArray(obj.siblings) || obj.siblings.some((s) => typeof s !== "string")) {
|
|
8657
|
+
return null;
|
|
8658
|
+
}
|
|
8659
|
+
return {
|
|
8660
|
+
proofKind: PROOF_KIND_BINARY,
|
|
8661
|
+
siblings: obj.siblings,
|
|
8662
|
+
key: obj.key,
|
|
8663
|
+
value: obj.value
|
|
8664
|
+
};
|
|
8665
|
+
}
|
|
8666
|
+
function hashToHex(hash) {
|
|
8667
|
+
return bytesToHex2(hash);
|
|
8668
|
+
}
|
|
8981
8669
|
|
|
8982
8670
|
// src/native-dev.ts
|
|
8983
8671
|
var NATIVE_DEV_HOST_API_VERSION = "0.1.0";
|
|
@@ -9236,7 +8924,6 @@ function pqm1MnemonicToMlDsa65Backend(mnemonic) {
|
|
|
9236
8924
|
|
|
9237
8925
|
// src/cluster-join.ts
|
|
9238
8926
|
var DEFAULT_CLUSTER_JOIN_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
9239
|
-
var DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT = REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT;
|
|
9240
8927
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
9241
8928
|
var MAX_UINT32 = (1n << 32n) - 1n;
|
|
9242
8929
|
function deriveClusterJoinOperatorId(operatorPubkey) {
|
|
@@ -9344,24 +9031,6 @@ function buildVoteClusterAdmitTxFields(args) {
|
|
|
9344
9031
|
})
|
|
9345
9032
|
};
|
|
9346
9033
|
}
|
|
9347
|
-
function buildPublishOperatorSealKeyTxFields(args) {
|
|
9348
|
-
return {
|
|
9349
|
-
chainId: args.chainId,
|
|
9350
|
-
nonce: args.nonce,
|
|
9351
|
-
maxFeePerGas: parseBigint(args.fee.maxFeePerGas, "maxFeePerGas"),
|
|
9352
|
-
maxPriorityFeePerGas: parseBigint(args.fee.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
9353
|
-
gasLimit: parseBigint(
|
|
9354
|
-
args.fee.gasLimit ?? DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT,
|
|
9355
|
-
"gasLimit"
|
|
9356
|
-
),
|
|
9357
|
-
to: nodeRegistryAddressHex(),
|
|
9358
|
-
value: 0n,
|
|
9359
|
-
input: encodePublishOperatorSealKeyCalldata({
|
|
9360
|
-
peerId: normalizeOperatorId(args.peerId),
|
|
9361
|
-
sealEk: normalizeOperatorSealEk(args.sealEk)
|
|
9362
|
-
})
|
|
9363
|
-
};
|
|
9364
|
-
}
|
|
9365
9034
|
async function submitRequestClusterJoin(args) {
|
|
9366
9035
|
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
9367
9036
|
const operatorPubkey = normalizeConsensusPubkey(args.operatorPubkey, "operatorPubkey");
|
|
@@ -9388,7 +9057,7 @@ async function submitRequestClusterJoin(args) {
|
|
|
9388
9057
|
operatorPubkey,
|
|
9389
9058
|
bondLythoshi: args.bondLythoshi
|
|
9390
9059
|
});
|
|
9391
|
-
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex
|
|
9060
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
9392
9061
|
}
|
|
9393
9062
|
async function submitVoteClusterAdmit(args) {
|
|
9394
9063
|
const clusterId = parseUint32(args.clusterId, "clusterId");
|
|
@@ -9415,62 +9084,9 @@ async function submitVoteClusterAdmit(args) {
|
|
|
9415
9084
|
operatorId: operatorIdHex,
|
|
9416
9085
|
voterPubkey: args.voterPubkey
|
|
9417
9086
|
});
|
|
9418
|
-
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex
|
|
9419
|
-
}
|
|
9420
|
-
async function submitPublishOperatorSealKey(args) {
|
|
9421
|
-
const operatorIdHex = normalizeOperatorId(args.peerId);
|
|
9422
|
-
const sealEk = normalizeOperatorSealEk(args.sealEk);
|
|
9423
|
-
const backend = pqm1MnemonicToMlDsa65Backend(args.mnemonic);
|
|
9424
|
-
const senderAddress = addressToTypedBech32("user", backend.addressBytes());
|
|
9425
|
-
const [chainId, nonce, quote] = await Promise.all([
|
|
9426
|
-
args.client.ethChainId(),
|
|
9427
|
-
args.client.lythGetTransactionCount(senderAddress),
|
|
9428
|
-
args.client.lythExecutionUnitPrice()
|
|
9429
|
-
]);
|
|
9430
|
-
const tx = buildPublishOperatorSealKeyTxFields({
|
|
9431
|
-
chainId,
|
|
9432
|
-
nonce,
|
|
9433
|
-
fee: resolveClusterJoinExecutionFee(quote, {
|
|
9434
|
-
...args,
|
|
9435
|
-
executionUnitLimit: args.executionUnitLimit ?? DEFAULT_OPERATOR_SEAL_KEY_EXECUTION_UNIT_LIMIT
|
|
9436
|
-
}),
|
|
9437
|
-
peerId: operatorIdHex,
|
|
9438
|
-
sealEk
|
|
9439
|
-
});
|
|
9440
|
-
const plaintext = buildPlaintextSubmission({ backend, tx });
|
|
9441
|
-
const txHash = await submitPlaintextTransaction(
|
|
9442
|
-
args.client,
|
|
9443
|
-
plaintext.signedTxWireHex,
|
|
9444
|
-
plaintext.innerTxHashHex
|
|
9445
|
-
);
|
|
9446
|
-
return {
|
|
9447
|
-
txHash,
|
|
9448
|
-
operatorIdHex,
|
|
9449
|
-
innerSighashHex: plaintext.innerSighashHex,
|
|
9450
|
-
signedTxWireBytes: plaintext.innerWireBytes
|
|
9451
|
-
};
|
|
9087
|
+
return submitClusterJoinTx(args.client, backend, tx, clusterId, operatorIdHex);
|
|
9452
9088
|
}
|
|
9453
|
-
async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex
|
|
9454
|
-
if (options.private !== false) {
|
|
9455
|
-
const encrypted = await buildEncryptedSubmission({
|
|
9456
|
-
client,
|
|
9457
|
-
backend,
|
|
9458
|
-
tx,
|
|
9459
|
-
clusterId: Number(clusterId),
|
|
9460
|
-
clusterSealKeys: options.clusterSealKeys,
|
|
9461
|
-
clusterSealKeysSource: options.clusterSealKeysSource,
|
|
9462
|
-
class: MempoolClass.ContractCall
|
|
9463
|
-
});
|
|
9464
|
-
assertRpcHash(await submitEncryptedEnvelope(client, encrypted.envelopeWireHex));
|
|
9465
|
-
return {
|
|
9466
|
-
txHash: encrypted.innerTxHashHex,
|
|
9467
|
-
clusterId: clusterId.toString(10),
|
|
9468
|
-
operatorIdHex,
|
|
9469
|
-
innerSighashHex: encrypted.innerSighashHex,
|
|
9470
|
-
signedTxWireBytes: encrypted.innerWireBytes,
|
|
9471
|
-
envelopeWireBytes: hexByteLength(encrypted.envelopeWireHex)
|
|
9472
|
-
};
|
|
9473
|
-
}
|
|
9089
|
+
async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex) {
|
|
9474
9090
|
const plaintext = buildPlaintextSubmission({ backend, tx });
|
|
9475
9091
|
const txHash = await submitPlaintextTransaction(
|
|
9476
9092
|
client,
|
|
@@ -9485,16 +9101,6 @@ async function submitClusterJoinTx(client, backend, tx, clusterId, operatorIdHex
|
|
|
9485
9101
|
signedTxWireBytes: plaintext.innerWireBytes
|
|
9486
9102
|
};
|
|
9487
9103
|
}
|
|
9488
|
-
function hexByteLength(value) {
|
|
9489
|
-
const clean = value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value;
|
|
9490
|
-
return clean.length / 2;
|
|
9491
|
-
}
|
|
9492
|
-
function assertRpcHash(value) {
|
|
9493
|
-
const bytes = hexToBytes2(value, "lyth_submitEncrypted tx hash");
|
|
9494
|
-
if (bytes.length !== 32) {
|
|
9495
|
-
throw new Error(`lyth_submitEncrypted tx hash must be 32 bytes, got ${bytes.length}`);
|
|
9496
|
-
}
|
|
9497
|
-
}
|
|
9498
9104
|
function adaptNativeClusterJoinRequest(request) {
|
|
9499
9105
|
return {
|
|
9500
9106
|
owner: request.owner ?? ZERO_ADDRESS,
|
|
@@ -9537,10 +9143,6 @@ function normalizeOperatorId(value) {
|
|
|
9537
9143
|
const bytes = typeof value === "string" ? hexToBytes2(value, "operatorId") : value;
|
|
9538
9144
|
return bytesToHex2(expectBytes(bytes, 32, "operatorId"));
|
|
9539
9145
|
}
|
|
9540
|
-
function normalizeOperatorSealEk(value) {
|
|
9541
|
-
const bytes = typeof value === "string" ? hexToBytes2(value, "sealEk") : value;
|
|
9542
|
-
return expectBytes(bytes, NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES, "sealEk").slice();
|
|
9543
|
-
}
|
|
9544
9146
|
function parseUint32(value, label) {
|
|
9545
9147
|
const parsed = parseBigint(value, label);
|
|
9546
9148
|
if (parsed < 0n || parsed > MAX_UINT32) {
|
|
@@ -11049,6 +10651,12 @@ function wordToBigint(word) {
|
|
|
11049
10651
|
}
|
|
11050
10652
|
return out;
|
|
11051
10653
|
}
|
|
10654
|
+
|
|
10655
|
+
// src/crypto/envelope.ts
|
|
10656
|
+
var MempoolClass = {
|
|
10657
|
+
CLOBOp: 3};
|
|
10658
|
+
|
|
10659
|
+
// src/market-actions.ts
|
|
11052
10660
|
var CLOB_MARKET_ID_DOMAIN_TAG = 193;
|
|
11053
10661
|
var NATIVE_MARKET_MODULE_ADDRESS_BYTES = "0x4d41524b45545f4e41544956455f4d4f445f5631";
|
|
11054
10662
|
var NATIVE_MARKET_MODULE_ADDRESS = addressToTypedBech32(
|
|
@@ -12381,6 +11989,6 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
12381
11989
|
// src/index.ts
|
|
12382
11990
|
var version = "0.4.18";
|
|
12383
11991
|
|
|
12384
|
-
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, DEFAULT_OPERATOR_SEAL_KEY_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_MULTISIG_MEMBERS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, MIN_MULTISIG_MEMBERS, 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, MULTISIG_ADDRESS_DERIVATION_DOMAIN2 as MULTISIG_WITNESS_ADDRESS_DERIVATION_DOMAIN, MULTISIG_WITNESS_DOMAIN, MarketActionError, MrvValidationError, MultisigError, 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_ARCHIVE_CHALLENGE_DOMAIN, NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED, NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_CHALLENGE_EPOCH_WINDOW, NODE_REGISTRY_CHARTER_COOLDOWN_EPOCHS, NODE_REGISTRY_CLUSTER_CHARTER_BYTES, NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS, NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS, 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_MESSAGE_DOMAIN_V2, NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT, NODE_REGISTRY_FORM_CLUSTER_THRESHOLD, NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES, NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH, NODE_REGISTRY_MERKLE_INNER_DOMAIN, NODE_REGISTRY_MERKLE_LEAF_DOMAIN, NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT, NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES, NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES, NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS, NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES, NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE, NODE_REGISTRY_TAG_CLUSTER_CHARTER, NODE_REGISTRY_TAG_SERVICE_SCORE, NODE_REGISTRY_TAG_TREASURY, NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN, NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD, 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, OperatorTrustError, 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, QUARANTINED_RPC_CODE, 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, TOKEN_FACTORY_CREATE_DEPOSIT_LYTHOSHI, TOKEN_FACTORY_FLAGS, TOKEN_FACTORY_KNOWN_FLAG_MASK, TOKEN_FACTORY_MAX_CREATOR_FEE_BPS, TOKEN_FACTORY_MAX_DECIMALS, TOKEN_FACTORY_NAME_MAX_BYTES, TOKEN_FACTORY_SELECTORS, TOKEN_FACTORY_SIGS, TOKEN_FACTORY_SYMBOL_MAX_BYTES, TOKEN_FACTORY_TOKEN_ID_DOMAIN_TAG, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, TX_EXTENSION_KIND_MULTISIG, TX_EXTENSION_MULTISIG_V1, TokenFactoryError, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, VRF_DOMAIN_TAG_MAX_BYTES, VRF_HEIGHT_NOT_FINALIZED_REVERT, VRF_OUTPUT_BYTES, VrfCallError, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, archiveMerkleInnerHash, archiveMerkleLeafHash, assembleMultisigSigned, assembleMultisigWitness, 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, buildPublishOperatorSealKeyTxFields, buildRequestClusterJoinTxFields, buildVoteClusterAdmitTxFields, categoryRoot, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, clusterApyPercent, clusterJoinRequestExists, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, computeQuoteLiquidity, consumeNativeEvents, decodeActiveCharter, decodeClusterCharter, decodeClusterDiversity, decodeClusterFormedEvent, decodeClusterJoinRequest, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOperatorSealKey, decodeOracleEvent, decodePendingCharter, decodeProbeAuthority, decodeScoreServiceProbe, decodeTimeWindow, decodeTokenFactoryTokenId, decodeTxFeedResponse, decodeVrfOutput, delegationAddressHex, denyRootFor, deriveArchiveChallenge, deriveClobMarketId, deriveClusterAnchorAddress, deriveClusterJoinOperatorId, deriveFeedId, deriveMrvContractAddress, deriveMultisigAddress, deriveMultisigAddressBytes, deriveNativeSpotMarketId, deriveNativeSpotOrderId, deriveTokenFactoryTokenId, destinationRoot, encodeAnswerArchiveChallengeCalldata, encodeAttestDkgReshareCalldata, encodeAttestServiceProbeCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelClusterJoinCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeClusterCharter, encodeCommitArchiveRootCalldata, encodeCreateFixedSupplyMrc20Calldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeCreateTokenCalldata, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeExpireClusterJoinCalldata, encodeFormClusterCalldata, encodeFormClusterV2Calldata, encodeGetClusterJoinRequestCalldata, encodeGetOperatorSealKeyCalldata, encodeGetPendingCharterCalldata, encodeGetProbeAuthorityCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeMultisigWitnessBody, 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, encodePublishOperatorSealKeyCalldata, encodeRecoverOperatorNodeCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeRequestClusterJoinCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetOperatorDisplayCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetProbeAuthorityCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeTokenFactoryAllowanceCalldata, encodeTokenFactoryApproveCalldata, encodeTokenFactoryBalanceOfCalldata, encodeTokenFactoryBurnCalldata, encodeTokenFactoryDecreaseAllowanceCalldata, encodeTokenFactoryDestroyCalldata, encodeTokenFactoryIncreaseAllowanceCalldata, encodeTokenFactoryMetadataCalldata, encodeTokenFactoryMintCalldata, encodeTokenFactorySetPausedCalldata, encodeTokenFactoryTotalSupplyCalldata, encodeTokenFactoryTransferCalldata, encodeTokenFactoryTransferFromCalldata, encodeTokenFactoryTransferOwnershipCalldata, encodeUndelegateCalldata, encodeUpdateCharterCalldata, encodeVoteClusterAdmitCalldata, encodeVrfEvaluateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formClusterMessage, formClusterMessageHex, formClusterMessageV2, formClusterMessageV2Hex, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isQuarantineError, isSinglePublicServiceProbeMask, isUnexpectedValueRevert, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, multisigBaseSighash, multisigMemberIndex, 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, protocolNonceForEpoch, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, readClusterJoinRequest, requestSighash, requireTypedAddress, resolveClusterJoinExecutionFee, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, selectTrustedOperator, selectTrustedOperatorForNetwork, serviceMaskToBitIndex, serviceProbeStatusLabel, setDestinationRoot, slotArchiveChallengePass, slotClusterCharter, slotClusterCharterDelegator, slotClusterCharterMembers, slotClusterServiceScore, slotEpochChallengeSeed, slotProbeAuthority, slotScoreServiceProbe, sortMultisigMembers, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitPublishOperatorSealKey, submitRequestClusterJoin, submitSighash, submitVoteClusterAdmit, tokenFactoryAddressHex, transactionFeeExposure, typedBech32ToAddress, updateCharterMessage, updateCharterMessageHex, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, validateMultisigRoster, validateTokenFactoryFlags, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, verifyOperatorGenesis, version, vrfAddressHex };
|
|
11992
|
+
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_MULTISIG_MEMBERS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, MIN_MULTISIG_MEMBERS, 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, MULTISIG_ADDRESS_DERIVATION_DOMAIN2 as MULTISIG_WITNESS_ADDRESS_DERIVATION_DOMAIN, MULTISIG_WITNESS_DOMAIN, MarketActionError, MrvValidationError, MultisigError, 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_ARCHIVE_CHALLENGE_DOMAIN, NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED, NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_CHALLENGE_EPOCH_WINDOW, NODE_REGISTRY_CHARTER_COOLDOWN_EPOCHS, NODE_REGISTRY_CLUSTER_CHARTER_BYTES, NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS, NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS, 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_MESSAGE_DOMAIN_V2, NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT, NODE_REGISTRY_FORM_CLUSTER_THRESHOLD, NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES, NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH, NODE_REGISTRY_MERKLE_INNER_DOMAIN, NODE_REGISTRY_MERKLE_LEAF_DOMAIN, NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT, NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES, NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS, NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES, NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE, NODE_REGISTRY_TAG_CLUSTER_CHARTER, NODE_REGISTRY_TAG_SERVICE_SCORE, NODE_REGISTRY_TAG_TREASURY, NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN, NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD, 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, OperatorTrustError, OracleEventError, PENDING_CHANGE_KIND_CODES, PRECOMPILE_ADDRESSES, PROOF_KIND_BINARY, 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, ProofVerifier, ProofVerifyError, ProverMarketError, PubkeyRegistryError, QUARANTINED_RPC_CODE, 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, TOKEN_FACTORY_CREATE_DEPOSIT_LYTHOSHI, TOKEN_FACTORY_FLAGS, TOKEN_FACTORY_KNOWN_FLAG_MASK, TOKEN_FACTORY_MAX_CREATOR_FEE_BPS, TOKEN_FACTORY_MAX_DECIMALS, TOKEN_FACTORY_NAME_MAX_BYTES, TOKEN_FACTORY_SELECTORS, TOKEN_FACTORY_SIGS, TOKEN_FACTORY_SYMBOL_MAX_BYTES, TOKEN_FACTORY_TOKEN_ID_DOMAIN_TAG, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, TX_EXTENSION_KIND_MULTISIG, TX_EXTENSION_MULTISIG_V1, TokenFactoryError, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, VRF_DOMAIN_TAG_MAX_BYTES, VRF_HEIGHT_NOT_FINALIZED_REVERT, VRF_OUTPUT_BYTES, VrfCallError, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, archiveMerkleInnerHash, archiveMerkleLeafHash, asBinaryProofEnvelope, assembleMultisigSigned, assembleMultisigWitness, 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, decodeActiveCharter, decodeClusterCharter, decodeClusterDiversity, decodeClusterFormedEvent, decodeClusterJoinRequest, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodePendingCharter, decodeProbeAuthority, decodeScoreServiceProbe, decodeTimeWindow, decodeTokenFactoryTokenId, decodeTxFeedResponse, decodeVrfOutput, delegationAddressHex, denyRootFor, deriveArchiveChallenge, deriveClobMarketId, deriveClusterAnchorAddress, deriveClusterJoinOperatorId, deriveFeedId, deriveMrvContractAddress, deriveMultisigAddress, deriveMultisigAddressBytes, deriveNativeSpotMarketId, deriveNativeSpotOrderId, deriveTokenFactoryTokenId, destinationRoot, encodeAnswerArchiveChallengeCalldata, encodeAttestDkgReshareCalldata, encodeAttestServiceProbeCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelClusterJoinCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeClusterCharter, encodeCommitArchiveRootCalldata, encodeCreateFixedSupplyMrc20Calldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeCreateTokenCalldata, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeExpireClusterJoinCalldata, encodeFormClusterCalldata, encodeFormClusterV2Calldata, encodeGetClusterJoinRequestCalldata, encodeGetPendingCharterCalldata, encodeGetProbeAuthorityCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeMultisigWitnessBody, 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, encodeSetOperatorDisplayCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetProbeAuthorityCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeTokenFactoryAllowanceCalldata, encodeTokenFactoryApproveCalldata, encodeTokenFactoryBalanceOfCalldata, encodeTokenFactoryBurnCalldata, encodeTokenFactoryDecreaseAllowanceCalldata, encodeTokenFactoryDestroyCalldata, encodeTokenFactoryIncreaseAllowanceCalldata, encodeTokenFactoryMetadataCalldata, encodeTokenFactoryMintCalldata, encodeTokenFactorySetPausedCalldata, encodeTokenFactoryTotalSupplyCalldata, encodeTokenFactoryTransferCalldata, encodeTokenFactoryTransferFromCalldata, encodeTokenFactoryTransferOwnershipCalldata, encodeUndelegateCalldata, encodeUpdateCharterCalldata, encodeVoteClusterAdmitCalldata, encodeVrfEvaluateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formClusterMessage, formClusterMessageHex, formClusterMessageV2, formClusterMessageV2Hex, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hashToHex, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isQuarantineError, isSinglePublicServiceProbeMask, isUnexpectedValueRevert, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, multisigBaseSighash, multisigMemberIndex, 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, proofVerifier, protocolNonceForEpoch, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, readClusterJoinRequest, requestSighash, requireTypedAddress, resolveClusterJoinExecutionFee, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, selectTrustedOperator, selectTrustedOperatorForNetwork, serviceMaskToBitIndex, serviceProbeStatusLabel, setDestinationRoot, slotArchiveChallengePass, slotClusterCharter, slotClusterCharterDelegator, slotClusterCharterMembers, slotClusterServiceScore, slotEpochChallengeSeed, slotProbeAuthority, slotScoreServiceProbe, sortMultisigMembers, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitRequestClusterJoin, submitSighash, submitVoteClusterAdmit, tokenFactoryAddressHex, transactionFeeExposure, typedBech32ToAddress, updateCharterMessage, updateCharterMessageHex, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, validateMultisigRoster, validateTokenFactoryFlags, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, verifyOperatorGenesis, version, vrfAddressHex };
|
|
12385
11993
|
//# sourceMappingURL=index.js.map
|
|
12386
11994
|
//# sourceMappingURL=index.js.map
|