@monolythium/core-sdk 0.4.23 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -9
- package/dist/crypto/index.cjs +51 -617
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +116 -31
- package/dist/crypto/index.d.ts +116 -31
- package/dist/crypto/index.js +44 -564
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +912 -951
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7411 -391
- package/dist/index.d.ts +7411 -391
- package/dist/index.js +876 -946
- package/dist/index.js.map +1 -1
- package/dist/ml-dsa-Drcmrw5h.d.cts +90 -0
- package/dist/ml-dsa-Drcmrw5h.d.ts +90 -0
- package/package.json +1 -1
- package/dist/submission-B4FmDnm_.d.cts +0 -7079
- package/dist/submission-B4FmDnm_.d.ts +0 -7079
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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,
|
|
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 };
|