@monolythium/core-sdk 0.4.23 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { L as MlDsa65Backend } from '../submission-B4FmDnm_.js';
2
- export { kb as ADDRESS_DERIVATION_DOMAIN, kc as CLUSTER_MLKEM_SHAMIR, kd as CLUSTER_MLKEM_SHAMIR_ALGO, ke as ClusterSealKeyEntryInput, U as ClusterSealKeys, V as ClusterSealKeysSource, kf as DKG_AEAD_TAG_LEN, kg as DKG_NONCE_LEN, kh as DecryptHint, ki as ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE, kj as ENUM_VARIANT_INDEX_ML_DSA_65, kk as EncryptedEnvelope, kl as EncryptedSubmission, I as EncryptionKey, km as JsonRpcCallClient, kn as LythiumSealEnvelope, ko as ML_DSA_65_PUBLIC_KEY_LEN, kp as ML_DSA_65_SEED_LEN, kq as ML_DSA_65_SIGNATURE_LEN, kr as ML_DSA_65_SIGNING_KEY_LEN, ks as ML_KEM_768_CIPHERTEXT_LEN, kt as ML_KEM_768_ENCAPSULATION_KEY_LEN, ku as ML_KEM_768_SHARED_SECRET_LEN, J as MempoolClass, H as NativeEvmTxFields, kv as NativeTxExtension, kw as NativeTxExtensionDescriptor, kx as NativeTxExtensionLike, ky as NonceAad, kz as OperatorSealKeypair, kA as PlaintextSubmission, kB as SEAL_COMMIT_LEN, kC as SEAL_DK_LEN, kD as SEAL_EK_LEN, kE as SEAL_KEM_CT_LEN, kF as SEAL_KEM_SEED_LEN, kG as SEAL_KEY_LEN, kH as SEAL_NONCE_LEN, kI as SEAL_SHARE_LEN, kJ as SEAL_TAG_LEN, kK as STANDARD_ALGO_NUMBER_ML_DSA_65, kL as SealRandomSource, kM as SealRecipient, kN as SealedSubmission, kO as bincodeDecryptHint, kP as bincodeEncryptedEnvelope, kQ as bincodeNonceAad, kR as bincodeSignedTransaction, kS as buildEncryptedEnvelope, kT as buildEncryptedSubmission, kU as buildPlaintextSubmission, kV as cryptoRandomSource, kW as encodeMlDsa65Opaque, kX as encodeSealEnvelope, kY as encodeTransactionForHash, kZ as encryptInnerTx, k_ as fetchEncryptionKey, k$ as generateOperatorSealKeypair, l0 as getClusterSealKeys, l1 as mlDsa65AddressBytes, l2 as mlDsa65AddressFromPublicKey, l3 as outerSigDigest, l4 as parseClusterSealKeys, l5 as sealRosterHash, l6 as sealToCluster, l7 as sealTransaction, l8 as submitEncryptedEnvelope, l9 as submitPlaintextTransaction, la as submitSealedTransaction, lb as submitTransactionWithPrivacy } from '../submission-B4FmDnm_.js';
1
+ import { a as MlDsa65Backend, N as NativeEvmTxFields } from '../ml-dsa-Drcmrw5h.js';
2
+ export { A as ADDRESS_DERIVATION_DOMAIN, E as ENUM_VARIANT_INDEX_ML_DSA_65, b as ML_DSA_65_PUBLIC_KEY_LEN, c as ML_DSA_65_SEED_LEN, d as ML_DSA_65_SIGNATURE_LEN, e as ML_DSA_65_SIGNING_KEY_LEN, M as MempoolClass, f as NativeTxExtension, g as NativeTxExtensionDescriptor, h as NativeTxExtensionLike, S as STANDARD_ALGO_NUMBER_ML_DSA_65, i as bincodeSignedTransaction, j as encodeMlDsa65Opaque, k as encodeTransactionForHash, m as mlDsa65AddressBytes, l as mlDsa65AddressFromPublicKey } from '../ml-dsa-Drcmrw5h.js';
3
3
 
4
4
  declare class BincodeWriter {
5
5
  #private;
@@ -20,35 +20,120 @@ declare function bytesToHex(bytes: Uint8Array): string;
20
20
  declare function hexToBytes(hex: string, label?: string): Uint8Array;
21
21
  declare function expectBytes(value: Uint8Array | readonly number[], len: number, label: string): Uint8Array;
22
22
 
23
- declare const PQM1_ALGO_TAG_MLDSA65 = 1;
24
- declare const PQM1_ALGO_TAG_MLDSA87_RESERVED = 2;
25
- declare const PQM1_ALGO_TAG_SLHDSA128S_RESERVED = 3;
26
- declare const PQM1_ALGO_TAG_FALCON512_RESERVED = 4;
27
- declare const PQM1_VERSION_V1 = 1;
28
- declare const PQM1_PAYLOAD_LEN = 32;
29
- declare const PQM1_ENTROPY_LEN = 30;
30
- declare const PQM1_V1_MNEMONIC_WORDS = 24;
31
- declare const PQM1_V1_MLDSA65_DOMAIN_TAG = "monolythium.pqm1.v1.mldsa65";
32
- type Pqm1ErrorKind = "badWordCount" | "bip39Decode" | "badPayloadLength" | "unsupportedAlgorithm" | "unsupportedVersion" | "missingRandom";
33
- declare class Pqm1Error extends Error {
34
- readonly kind: Pqm1ErrorKind;
35
- constructor(kind: Pqm1ErrorKind, message: string);
23
+ /**
24
+ * Standard BIP-39 -> ML-DSA-65 wallet key derivation.
25
+ *
26
+ * A wallet mnemonic is a plain 24-word English BIP-39 phrase (256-bit /
27
+ * 32-byte entropy) with NO custom header bytes. The signing seed is derived
28
+ * from the standard BIP-39 PBKDF2 seed via a domain-separated SHAKE256:
29
+ *
30
+ * seed64 = BIP-39 PBKDF2 seed = mnemonicToSeedSync(mnemonic, "")
31
+ * (HMAC-SHA512, 2048 rounds, 64 bytes)
32
+ * mldsa65Seed = shake256( utf8("monolythium.mldsa65.v1") || seed64,
33
+ * { dkLen: 32 } )
34
+ *
35
+ * `MlDsa65Backend.fromSeed(mldsa65Seed)` then yields the deterministic
36
+ * ML-DSA-65 keypair / address. This is the SDK foundation imported by every
37
+ * wallet + monarch-desktop through `@monolythium/core-sdk/crypto`.
38
+ */
39
+ /** Number of words in a Monolythium wallet mnemonic (256-bit BIP-39). */
40
+ declare const MLDSA65_MNEMONIC_WORDS = 24;
41
+ /** Domain-separation tag mixed into the ML-DSA-65 seed derivation. */
42
+ declare const MLDSA65_SEED_DOMAIN = "monolythium.mldsa65.v1";
43
+ type MnemonicErrorKind = "badWordCount" | "bip39Decode" | "missingRandom";
44
+ declare class MnemonicError extends Error {
45
+ readonly kind: MnemonicErrorKind;
46
+ constructor(kind: MnemonicErrorKind, message: string);
36
47
  }
37
- interface Pqm1Payload {
38
- algoTag: typeof PQM1_ALGO_TAG_MLDSA65;
39
- version: typeof PQM1_VERSION_V1;
40
- entropy: Uint8Array;
41
- bytes: Uint8Array;
48
+ type MnemonicRng = (bytes: Uint8Array) => void;
49
+ /** Generate a fresh 24-word BIP-39 mnemonic from 32 bytes of entropy. */
50
+ declare function generateMnemonic(rng?: MnemonicRng): string;
51
+ /**
52
+ * Returns `true` only when `mnemonic` is exactly 24 words AND passes the
53
+ * BIP-39 wordlist + checksum validation.
54
+ */
55
+ declare function validateMnemonic(mnemonic: string): boolean;
56
+ /**
57
+ * Derive the 32-byte ML-DSA-65 seed from a 24-word BIP-39 mnemonic.
58
+ * Throws a typed {@link MnemonicError} when the input is not a valid 24-word
59
+ * mnemonic.
60
+ */
61
+ declare function mnemonicToMlDsa65Seed(mnemonic: string): Uint8Array;
62
+ /** Derive the ML-DSA-65 signing backend from a 24-word BIP-39 mnemonic. */
63
+ declare function mnemonicToMlDsa65Backend(mnemonic: string): MlDsa65Backend;
64
+ /** Derive the wallet address (0x-hex) from a 24-word BIP-39 mnemonic. */
65
+ declare function mnemonicToAddress(mnemonic: string): string;
66
+
67
+ interface JsonRpcCallClient {
68
+ call<T>(method: string, params?: unknown): Promise<T>;
69
+ }
70
+ /**
71
+ * A built plaintext submission — the bincode-encoded chain-side
72
+ * `SignedTransaction` (`0x`-prefixed hex) ready to hand to
73
+ * `mesh_submitTx`, plus the canonical hashes the wallet validates the
74
+ * node echo against.
75
+ *
76
+ * Mirrors the chain-side artefacts produced by the Rust SDK's
77
+ * `build_chain_signed_tx` (`mono-core/crates/core/sdk/src/tx.rs`): the
78
+ * ML-DSA-65 signature is taken over the canonical chain-side `sighash`
79
+ * (keccak-256 of the 0x01-tagged preimage) and the canonical native tx
80
+ * hash is the keccak-256 of the 0x02-tagged preimage with the signature
81
+ * and public key appended.
82
+ */
83
+ interface PlaintextSubmission {
84
+ /** Bincode `SignedTransaction` wire bytes, `0x`-prefixed. */
85
+ signedTxWireHex: string;
86
+ /** Canonical native tx hash the node echoes on admission. */
87
+ innerTxHashHex: string;
88
+ /** Canonical chain-side sighash that was signed. */
89
+ innerSighashHex: string;
90
+ /** Length in bytes of the bincode `SignedTransaction`. */
91
+ innerWireBytes: number;
42
92
  }
43
- type Pqm1Rng = (bytes: Uint8Array) => void;
44
- declare function assemblePqm1Payload(entropy: Uint8Array | readonly number[]): Uint8Array;
45
- declare function parsePqm1Payload(payload: Uint8Array | readonly number[]): Pqm1Payload;
46
- declare function pqm1PayloadToMnemonic(payload: Uint8Array | readonly number[]): string;
47
- declare function pqm1MnemonicToPayload(mnemonic: string): Pqm1Payload;
48
- declare function derivePqm1MlDsa65SeedFromPayload(payload: Uint8Array | readonly number[]): Uint8Array;
49
- declare function pqm1MnemonicToMlDsa65Seed(mnemonic: string): Uint8Array;
50
- declare function pqm1MnemonicToMlDsa65Backend(mnemonic: string): MlDsa65Backend;
51
- declare function pqm1MnemonicToAddress(mnemonic: string): string;
52
- declare function generatePqm1Mnemonic(rng?: Pqm1Rng): string;
93
+ /**
94
+ * Build a PLAINTEXT submission the sole submit path since the v2
95
+ * re-genesis dropped the encrypted (LythiumSeal) mempool.
96
+ *
97
+ * It re-shapes the native tx into the chain-side `SignedTransaction`,
98
+ * signs over the canonical `sighash` with the ML-DSA-65 backend,
99
+ * bincode-serializes the result, and `0x`-hex-encodes it. The bytes are
100
+ * forwarded verbatim through `mesh_submitTx` (the node routes them to
101
+ * `MempoolTx::plaintext` via `submit_raw`).
102
+ *
103
+ * Mirrors `TxClient::submit_plaintext` in the Rust SDK.
104
+ */
105
+ declare function buildPlaintextSubmission(args: {
106
+ backend: MlDsa65Backend;
107
+ tx: NativeEvmTxFields;
108
+ }): PlaintextSubmission;
109
+ /**
110
+ * Submit a bincode-encoded chain-side `SignedTransaction` (`0x`-hex)
111
+ * through the plaintext `mesh_submitTx` path and validate the node's
112
+ * echoed canonical tx hash against the locally computed one.
113
+ *
114
+ * Mirrors the validation in `TxClient::submit_plaintext`: the node
115
+ * echoes the 32-byte canonical native tx hash on admission, and any
116
+ * mismatch (or non-32-byte response) is rejected loud so a wallet never
117
+ * trusts a hash it did not derive itself.
118
+ *
119
+ * @returns the validated canonical native tx hash (`0x`-prefixed).
120
+ */
121
+ declare function submitPlaintextTransaction(client: JsonRpcCallClient, signedTxWireHex: string, expectedTxHashHex: string): Promise<string>;
122
+ /**
123
+ * Build, sign, and submit a native transaction through the plaintext
124
+ * `mesh_submitTx` path.
125
+ *
126
+ * Mirrors `TxClient::build_sign_submit` in the Rust SDK. The encrypted
127
+ * (LythiumSeal) submit path was removed at the v2 re-genesis, so this is
128
+ * the single build-sign-submit entry point.
129
+ *
130
+ * @returns the node-echoed-and-validated canonical native tx hash
131
+ * (`0x`-prefixed).
132
+ */
133
+ declare function submitTransaction(args: {
134
+ client: JsonRpcCallClient;
135
+ backend: MlDsa65Backend;
136
+ tx: NativeEvmTxFields;
137
+ }): Promise<string>;
53
138
 
54
- export { BincodeWriter, MlDsa65Backend, PQM1_ALGO_TAG_FALCON512_RESERVED, PQM1_ALGO_TAG_MLDSA65, PQM1_ALGO_TAG_MLDSA87_RESERVED, PQM1_ALGO_TAG_SLHDSA128S_RESERVED, PQM1_ENTROPY_LEN, PQM1_PAYLOAD_LEN, PQM1_V1_MLDSA65_DOMAIN_TAG, PQM1_V1_MNEMONIC_WORDS, PQM1_VERSION_V1, Pqm1Error, type Pqm1ErrorKind, type Pqm1Payload, type Pqm1Rng, assemblePqm1Payload, bytesToHex, concatBytes, derivePqm1MlDsa65SeedFromPayload, expectBytes, generatePqm1Mnemonic, hexToBytes, parsePqm1Payload, pqm1MnemonicToAddress, pqm1MnemonicToMlDsa65Backend, pqm1MnemonicToMlDsa65Seed, pqm1MnemonicToPayload, pqm1PayloadToMnemonic };
139
+ export { BincodeWriter, type JsonRpcCallClient, MLDSA65_MNEMONIC_WORDS, MLDSA65_SEED_DOMAIN, MlDsa65Backend, MnemonicError, type MnemonicErrorKind, type MnemonicRng, NativeEvmTxFields, type PlaintextSubmission, buildPlaintextSubmission, bytesToHex, concatBytes, expectBytes, generateMnemonic, hexToBytes, mnemonicToAddress, mnemonicToMlDsa65Backend, mnemonicToMlDsa65Seed, submitPlaintextTransaction, submitTransaction, validateMnemonic };