@theqrl/wallet.js 0.1.2 → 0.2.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.
Files changed (47) hide show
  1. package/README.md +195 -1
  2. package/dist/cjs/package.json +1 -0
  3. package/dist/cjs/wallet.js +4856 -0
  4. package/dist/mjs/package.json +1 -0
  5. package/dist/mjs/wallet.js +4841 -0
  6. package/package.json +22 -8
  7. package/src/index.js +33 -13
  8. package/src/qrl/wordlist.js +11 -5
  9. package/src/utils/bytes.js +59 -0
  10. package/src/wallet/common/address.js +94 -0
  11. package/src/wallet/common/constants.js +16 -0
  12. package/src/wallet/common/descriptor.js +70 -0
  13. package/src/wallet/common/seed.js +123 -0
  14. package/src/wallet/common/wallettype.js +21 -0
  15. package/src/wallet/factory.js +39 -0
  16. package/src/wallet/misc/mnemonic.js +77 -0
  17. package/src/wallet/ml_dsa_87/crypto.js +90 -0
  18. package/src/wallet/ml_dsa_87/descriptor.js +18 -0
  19. package/src/wallet/ml_dsa_87/wallet.js +158 -0
  20. package/types/index.d.ts +13 -0
  21. package/types/index.d.ts.map +1 -0
  22. package/types/qrl/wordlist.d.ts +11 -0
  23. package/types/qrl/wordlist.d.ts.map +1 -0
  24. package/types/utils/bytes.d.ts +27 -0
  25. package/types/utils/bytes.d.ts.map +1 -0
  26. package/types/wallet/common/address.d.ts +17 -0
  27. package/types/wallet/common/address.d.ts.map +1 -0
  28. package/types/wallet/common/constants.d.ts +13 -0
  29. package/types/wallet/common/constants.d.ts.map +1 -0
  30. package/types/wallet/common/descriptor.d.ts +32 -0
  31. package/types/wallet/common/descriptor.d.ts.map +1 -0
  32. package/types/wallet/common/seed.d.ts +67 -0
  33. package/types/wallet/common/seed.d.ts.map +1 -0
  34. package/types/wallet/common/wallettype.d.ts +19 -0
  35. package/types/wallet/common/wallettype.d.ts.map +1 -0
  36. package/types/wallet/factory.d.ts +9 -0
  37. package/types/wallet/factory.d.ts.map +1 -0
  38. package/types/wallet/misc/mnemonic.d.ts +13 -0
  39. package/types/wallet/misc/mnemonic.d.ts.map +1 -0
  40. package/types/wallet/ml_dsa_87/crypto.d.ts +24 -0
  41. package/types/wallet/ml_dsa_87/crypto.d.ts.map +1 -0
  42. package/types/wallet/ml_dsa_87/descriptor.d.ts +8 -0
  43. package/types/wallet/ml_dsa_87/descriptor.d.ts.map +1 -0
  44. package/types/wallet/ml_dsa_87/wallet.d.ts +74 -0
  45. package/types/wallet/ml_dsa_87/wallet.d.ts.map +1 -0
  46. package/src/dilithium.js +0 -158
  47. package/src/utils/mnemonic.js +0 -93
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @module wallet/ml_dsa_87/crypto
3
+ */
4
+
5
+ import {
6
+ cryptoSignKeypair,
7
+ cryptoSign,
8
+ cryptoSignVerify,
9
+ CryptoBytes,
10
+ CryptoPublicKeyBytes,
11
+ CryptoSecretKeyBytes,
12
+ } from '@theqrl/mldsa87';
13
+
14
+ /**
15
+ * Generate a keypair.
16
+ * @returns {{ pk: Uint8Array, sk: Uint8Array }}
17
+ */
18
+ function keygen(seed) {
19
+ const pk = new Uint8Array(CryptoPublicKeyBytes);
20
+ const sk = new Uint8Array(CryptoSecretKeyBytes);
21
+ const seedBytes = new Uint8Array(seed.hashSHA256());
22
+ cryptoSignKeypair(seedBytes, pk, sk);
23
+ return { pk, sk };
24
+ }
25
+
26
+ /**
27
+ * Check if input is a valid byte array (Uint8Array or Buffer).
28
+ * @param {unknown} input
29
+ * @returns {boolean}
30
+ */
31
+ function isBytes(input) {
32
+ return input instanceof Uint8Array;
33
+ }
34
+
35
+ /**
36
+ * Sign a message.
37
+ * @param {Uint8Array} sk - Secret key (must be CryptoSecretKeyBytes bytes)
38
+ * @param {Uint8Array} message - Message to sign
39
+ * @returns {Uint8Array} signature
40
+ * @throws {Error} If sk or message is invalid
41
+ */
42
+ function sign(sk, message) {
43
+ if (!isBytes(sk)) {
44
+ throw new Error('sk must be Uint8Array or Buffer');
45
+ }
46
+ if (sk.length !== CryptoSecretKeyBytes) {
47
+ throw new Error(`sk must be ${CryptoSecretKeyBytes} bytes, got ${sk.length}`);
48
+ }
49
+ if (!isBytes(message)) {
50
+ throw new Error('message must be Uint8Array or Buffer');
51
+ }
52
+
53
+ const sm = cryptoSign(message, sk);
54
+ let signature = new Uint8Array(CryptoBytes);
55
+ signature = sm.slice(0, CryptoBytes);
56
+ return signature;
57
+ }
58
+
59
+ /**
60
+ * Verify a signature.
61
+ * @param {Uint8Array} signature - Signature to verify (must be CryptoBytes bytes)
62
+ * @param {Uint8Array} message - Original message
63
+ * @param {Uint8Array} pk - Public key (must be CryptoPublicKeyBytes bytes)
64
+ * @returns {boolean}
65
+ * @throws {Error} If signature, message, or pk is invalid
66
+ */
67
+ function verify(signature, message, pk) {
68
+ if (!isBytes(signature)) {
69
+ throw new Error('signature must be Uint8Array or Buffer');
70
+ }
71
+ if (signature.length !== CryptoBytes) {
72
+ throw new Error(`signature must be ${CryptoBytes} bytes, got ${signature.length}`);
73
+ }
74
+ if (!isBytes(message)) {
75
+ throw new Error('message must be Uint8Array or Buffer');
76
+ }
77
+ if (!isBytes(pk)) {
78
+ throw new Error('pk must be Uint8Array or Buffer');
79
+ }
80
+ if (pk.length !== CryptoPublicKeyBytes) {
81
+ throw new Error(`pk must be ${CryptoPublicKeyBytes} bytes, got ${pk.length}`);
82
+ }
83
+
84
+ const sigBytes = new Uint8Array(signature);
85
+ const msgBytes = new Uint8Array(message);
86
+ const pkBytes = new Uint8Array(pk);
87
+ return cryptoSignVerify(sigBytes, msgBytes, pkBytes);
88
+ }
89
+
90
+ export { keygen, sign, verify };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * ML-DSA-87-specific descriptor helpers.
3
+ * @module /wallet/ml_dsa_87/descriptor
4
+ */
5
+
6
+ import { Descriptor, getDescriptorBytes } from '../common/descriptor.js';
7
+ import { WalletType } from '../common/wallettype.js';
8
+
9
+ /**
10
+ * New ML-DSA-87 descriptor with optional 2-byte metadata.
11
+ * @param {[number, number]} [metadata=[0,0]]
12
+ * @returns {Descriptor}
13
+ */
14
+ function newMLDSA87Descriptor(metadata = [0, 0]) {
15
+ return new Descriptor(getDescriptorBytes(WalletType.ML_DSA_87, metadata));
16
+ }
17
+
18
+ export { newMLDSA87Descriptor };
@@ -0,0 +1,158 @@
1
+ /**
2
+ * ML-DSA-87 Wallet object encapsulating descriptor, seeds and keypair.
3
+ * @module wallet/ml_dsa_87/wallet
4
+ */
5
+
6
+ /** @typedef {import('../common/descriptor.js').Descriptor} Descriptor */
7
+ import randomBytes from 'randombytes';
8
+ import { bytesToHex } from '@noble/hashes/utils.js';
9
+ import { mnemonicToBin, binToMnemonic } from '../misc/mnemonic.js';
10
+ import { getAddressFromPKAndDescriptor, addressToString } from '../common/address.js';
11
+ import { Seed, ExtendedSeed } from '../common/seed.js';
12
+ import { newMLDSA87Descriptor } from './descriptor.js';
13
+ import { keygen, sign, verify } from './crypto.js';
14
+
15
+ class Wallet {
16
+ /**
17
+ * @param {{descriptor: Descriptor, seed: Seed, pk: Uint8Array, sk: Uint8Array}} opts
18
+ */
19
+ constructor({ descriptor, seed, pk, sk }) {
20
+ this.descriptor = descriptor;
21
+ this.seed = seed;
22
+ this.pk = pk;
23
+ this.sk = sk;
24
+ this.extendedSeed = ExtendedSeed.newExtendedSeed(descriptor, seed);
25
+ }
26
+
27
+ /**
28
+ * Create a new random wallet(non-deterministic).
29
+ * @param {[number, number]} [metadata=[0,0] ]
30
+ * @returns {Wallet}
31
+ */
32
+ static newWallet(metadata = [0, 0]) {
33
+ const descriptor = newMLDSA87Descriptor(metadata);
34
+ const seedBytes = randomBytes(48);
35
+ const seed = new Seed(seedBytes);
36
+ const { pk, sk } = keygen(seed);
37
+ return new Wallet({ descriptor, seed, pk, sk });
38
+ }
39
+
40
+ /**
41
+ * @param {Seed} seed
42
+ * @param {[number, number]} [metadata=[0,0]]
43
+ * @returns {Wallet}
44
+ */
45
+ static newWalletFromSeed(seed, metadata = [0, 0]) {
46
+ const descriptor = newMLDSA87Descriptor(metadata);
47
+ const { pk, sk } = keygen(seed);
48
+ return new Wallet({ descriptor, seed, pk, sk });
49
+ }
50
+
51
+ /**
52
+ * @param {ExtendedSeed} extendedSeed
53
+ * @returns {Wallet}
54
+ */
55
+ static newWalletFromExtendedSeed(extendedSeed) {
56
+ const descriptor = extendedSeed.getDescriptor();
57
+ const seed = extendedSeed.getSeed();
58
+ const { pk, sk } = keygen(seed);
59
+ return new Wallet({ descriptor, seed, pk, sk });
60
+ }
61
+
62
+ /**
63
+ * @param {string} mnemonic
64
+ * @returns {Wallet}
65
+ */
66
+ static newWalletFromMnemonic(mnemonic) {
67
+ const bin = mnemonicToBin(mnemonic);
68
+ const extendedSeed = new ExtendedSeed(bin);
69
+ return this.newWalletFromExtendedSeed(extendedSeed);
70
+ }
71
+
72
+ /** @returns {Uint8Array} */
73
+ getAddress() {
74
+ return getAddressFromPKAndDescriptor(this.pk, this.descriptor);
75
+ }
76
+
77
+ /** @returns {string} */
78
+ getAddressStr() {
79
+ return addressToString(this.getAddress());
80
+ }
81
+
82
+ /** @returns {Descriptor} */
83
+ getDescriptor() {
84
+ return this.descriptor;
85
+ }
86
+
87
+ /** @returns {ExtendedSeed} */
88
+ getExtendedSeed() {
89
+ return this.extendedSeed;
90
+ }
91
+
92
+ /** @returns {Seed} */
93
+ getSeed() {
94
+ return this.seed;
95
+ }
96
+
97
+ /** @returns {string} hex(ExtendedSeed) */
98
+ getHexExtendedSeed() {
99
+ return `0x${bytesToHex(this.extendedSeed.toBytes())}`;
100
+ }
101
+
102
+ /** @returns {string} */
103
+ getMnemonic() {
104
+ return binToMnemonic(this.getExtendedSeed().toBytes());
105
+ }
106
+
107
+ /** @returns {Uint8Array} */
108
+ getPK() {
109
+ return this.pk.slice();
110
+ }
111
+
112
+ /** @returns {Uint8Array} */
113
+ getSK() {
114
+ return this.sk.slice();
115
+ }
116
+
117
+ /**
118
+ * Sign a message.
119
+ * @param {Uint8Array} message
120
+ * @returns {Uint8Array} Signature bytes.
121
+ */
122
+ sign(message) {
123
+ return sign(this.sk, message);
124
+ }
125
+
126
+ /**
127
+ * Verify a signature.
128
+ * @param {Uint8Array} signature
129
+ * @param {Uint8Array} message
130
+ * @param {Uint8Array} pk
131
+ * @returns {boolean}
132
+ */
133
+ static verify(signature, message, pk) {
134
+ return verify(signature, message, pk);
135
+ }
136
+
137
+ /**
138
+ * Securely zeroize sensitive key material.
139
+ * Call this when the wallet is no longer needed to minimize
140
+ * the window where secrets exist in memory.
141
+ *
142
+ * Note: JavaScript garbage collection may retain copies;
143
+ * this provides best-effort zeroization.
144
+ */
145
+ zeroize() {
146
+ if (this.sk) {
147
+ this.sk.fill(0);
148
+ }
149
+ if (this.seed && this.seed.bytes) {
150
+ this.seed.bytes.fill(0);
151
+ }
152
+ if (this.extendedSeed && this.extendedSeed.bytes) {
153
+ this.extendedSeed.bytes.fill(0);
154
+ }
155
+ }
156
+ }
157
+
158
+ export { Wallet };
@@ -0,0 +1,13 @@
1
+ import { Seed } from "./wallet/common/seed.js";
2
+ import { SEED_SIZE } from "./wallet/common/constants.js";
3
+ import { ExtendedSeed } from "./wallet/common/seed.js";
4
+ import { EXTENDED_SEED_SIZE } from "./wallet/common/constants.js";
5
+ import { Descriptor } from "./wallet/common/descriptor.js";
6
+ import { DESCRIPTOR_SIZE } from "./wallet/common/constants.js";
7
+ import { newMLDSA87Descriptor } from "./wallet/ml_dsa_87/descriptor.js";
8
+ import { getAddressFromPKAndDescriptor } from "./wallet/common/address.js";
9
+ import { WalletType } from "./wallet/common/wallettype.js";
10
+ import { newWalletFromExtendedSeed } from "./wallet/factory.js";
11
+ import { Wallet as MLDSA87 } from "./wallet/ml_dsa_87/wallet.js";
12
+ export { Seed, SEED_SIZE, ExtendedSeed, EXTENDED_SEED_SIZE, Descriptor, DESCRIPTOR_SIZE, newMLDSA87Descriptor, getAddressFromPKAndDescriptor, WalletType, newWalletFromExtendedSeed, MLDSA87 };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Mnemonic word list used by encoding/decoding utilities.
3
+ * @module qrl/wordlist
4
+ */
5
+ /**
6
+ * Ordered list of mnemonic words.
7
+ * @readonly
8
+ * @type {string[]}
9
+ */
10
+ export const WordList: string[];
11
+ //# sourceMappingURL=wordlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wordlist.d.ts","sourceRoot":"","sources":["../../src/qrl/wordlist.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,uBAFU,MAAM,EAAE,CAmgIhB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @param {unknown} input
3
+ * @returns {boolean}
4
+ */
5
+ export function isUint8(input: unknown): boolean;
6
+ /**
7
+ * Accepts strings with optional 0x/0X prefix and separators(space, :, _, -).
8
+ * @param {unknown} input
9
+ * @returns {boolean}
10
+ */
11
+ export function isHexLike(input: unknown): boolean;
12
+ /**
13
+ * Remove 0x prefix and all non-hex chars.
14
+ * @param {string} hex
15
+ * @returns {string}
16
+ */
17
+ export function cleanHex(hex: string): string;
18
+ /**
19
+ * Convert various inputs to a fixed-length byte array.
20
+ * Supports hex string(with/without 0x), Uint8Array, Buffer, number[].
21
+ * @param {string|Uint8Array|Buffer|number[]} input
22
+ * @param {number} expectedLen
23
+ * @param {string} [label='bytes']
24
+ * @returns {Uint8Array}
25
+ */
26
+ export function toFixedU8(input: string | Uint8Array | Buffer | number[], expectedLen: number, label?: string): Uint8Array;
27
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/utils/bytes.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH,+BAHW,OAAO,GACL,OAAO,CAInB;AAED;;;;GAIG;AACH,iCAHW,OAAO,GACL,OAAO,CAMnB;AAED;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;GAOG;AACH,iCALW,MAAM,GAAC,UAAU,GAAC,MAAM,GAAC,MAAM,EAAE,eACjC,MAAM,UACN,MAAM,GACJ,UAAU,CAiBtB"}
@@ -0,0 +1,17 @@
1
+ export type Descriptor = any;
2
+ /**
3
+ * Convert address bytes to string form.
4
+ * @param {Uint8Array} addrBytes
5
+ * @returns {string}
6
+ * @throws {Error} If length mismatch.
7
+ */
8
+ export function addressToString(addrBytes: Uint8Array): string;
9
+ /**
10
+ * Derive an address from a public key and descriptor.
11
+ * @param {Uint8Array} pk
12
+ * @param {Descriptor} descriptor
13
+ * @returns {Uint8Array} 20-byte address.
14
+ * @throws {Error} If pk length mismatch.
15
+ */
16
+ export function getAddressFromPKAndDescriptor(pk: Uint8Array, descriptor: any): Uint8Array;
17
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/wallet/common/address.js"],"names":[],"mappings":";AAUA;;;;;GAKG;AACH,2CAJW,UAAU,GACR,MAAM,CASlB;AAED;;;;;;GAMG;AACH,kDALW,UAAU,oBAER,UAAU,CAsBtB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Constants used across wallet components.
3
+ * @module wallet/common/constants
4
+ */
5
+ /** @type {number} Size in bytes of the 3-byte descriptor */
6
+ export const DESCRIPTOR_SIZE: number;
7
+ /** @type {number} Address length in bytes */
8
+ export const ADDRESS_SIZE: number;
9
+ /** @type {number} Seed length in bytes */
10
+ export const SEED_SIZE: number;
11
+ /** @type {number} Extended seed length in bytes */
12
+ export const EXTENDED_SEED_SIZE: number;
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/wallet/common/constants.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4DAA4D;AAC5D,8BADW,MAAM,CACS;AAE1B,6CAA6C;AAC7C,2BADW,MAAM,CACO;AAExB,0CAA0C;AAC1C,wBADW,MAAM,CACI;AAErB,mDAAmD;AACnD,iCADW,MAAM,CACsC"}
@@ -0,0 +1,32 @@
1
+ export class Descriptor {
2
+ /**
3
+ * Constructor: accepts hex string / Uint8Array / Buffer / number[].
4
+ * @param {string|Uint8Array|Buffer|number[]} input
5
+ * @returns {Descriptor}
6
+ */
7
+ static from(input: string | Uint8Array | Buffer | number[]): Descriptor;
8
+ /**
9
+ * @param {Uint8Array|number[]} bytes Must be exactly 3 bytes.
10
+ * @throws {Error} If size is not 3 or wallet type is invalid.
11
+ */
12
+ constructor(bytes: Uint8Array | number[]);
13
+ /** @private @type {Uint8Array} */
14
+ private bytes;
15
+ /**
16
+ * @returns {number}
17
+ */
18
+ type(): number;
19
+ /**
20
+ * Copy of internal bytes.
21
+ * @returns {Uint8Array}
22
+ */
23
+ toBytes(): Uint8Array;
24
+ }
25
+ /**
26
+ * Build descriptor bytes from parts.
27
+ * @param {number} walletType byte.
28
+ * @param {[number, number]} [metadata=[0,0]] Two metadata bytes.
29
+ * @returns {Uint8Array} 3 bytes.
30
+ */
31
+ export function getDescriptorBytes(walletType: number, metadata?: [number, number]): Uint8Array;
32
+ //# sourceMappingURL=descriptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/wallet/common/descriptor.js"],"names":[],"mappings":"AAWA;IA+BE;;;;OAIG;IACH,mBAHW,MAAM,GAAC,UAAU,GAAC,MAAM,GAAC,MAAM,EAAE,GAC/B,UAAU,CAItB;IArCD;;;OAGG;IACH,mBAHW,UAAU,GAAC,MAAM,EAAE,EAY7B;IALC,kCAAkC;IAClC,cAAmC;IAMrC;;OAEG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,WAFa,UAAU,CAItB;CAUF;AAED;;;;;GAKG;AACH,+CAJW,MAAM,aACN,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,UAAU,CAWtB"}
@@ -0,0 +1,67 @@
1
+ export class Seed {
2
+ /**
3
+ * Constructor: accepts hex string / Uint8Array / Buffer / number[].
4
+ * @param {string|Uint8Array|Buffer|number[]} input
5
+ * @returns {Seed}
6
+ */
7
+ static from(input: string | Uint8Array | Buffer | number[]): Seed;
8
+ /**
9
+ * @param {Uint8Array} bytes Exactly 48 bytes.
10
+ * @throws {Error} If size mismatch.
11
+ */
12
+ constructor(bytes: Uint8Array);
13
+ bytes: Uint8Array;
14
+ /** @returns {Uint8Array} */
15
+ hashSHA256(): Uint8Array;
16
+ /**
17
+ * Copy of internal seed bytes.
18
+ * @returns {Uint8Array}
19
+ */
20
+ toBytes(): Uint8Array;
21
+ }
22
+ export class ExtendedSeed {
23
+ /**
24
+ * Build from components.
25
+ * @param {Descriptor} desc
26
+ * @param {Seed} seed
27
+ * @returns {ExtendedSeed}
28
+ */
29
+ static newExtendedSeed(desc: Descriptor, seed: Seed): ExtendedSeed;
30
+ /**
31
+ * Constructor: accepts hex string / Uint8Array / Buffer / number[].
32
+ * @param {string|Uint8Array|Buffer|number[]} input
33
+ * @returns {ExtendedSeed}
34
+ */
35
+ static from(input: string | Uint8Array | Buffer | number[]): ExtendedSeed;
36
+ /**
37
+ * Layout: [3 bytes descriptor] || [48 bytes seed].
38
+ * @param {Uint8Array} bytes Exactly 51 bytes.
39
+ * @throws {Error} If size mismatch.
40
+ */
41
+ constructor(bytes: Uint8Array);
42
+ /** @private @type {Uint8Array} */
43
+ private bytes;
44
+ /**
45
+ * @returns {Descriptor}
46
+ */
47
+ getDescriptor(): Descriptor;
48
+ /**
49
+ * @returns {Uint8Array} Descriptor(3 bytes).
50
+ */
51
+ getDescriptorBytes(): Uint8Array;
52
+ /**
53
+ * @returns {Uint8Array} Seed bytes(48 bytes).
54
+ */
55
+ getSeedBytes(): Uint8Array;
56
+ /**
57
+ * @returns {Seed}
58
+ */
59
+ getSeed(): Seed;
60
+ /**
61
+ * Copy of internal seed bytes.
62
+ * @returns {Uint8Array}
63
+ */
64
+ toBytes(): Uint8Array;
65
+ }
66
+ import { Descriptor } from "./descriptor.js";
67
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/wallet/common/seed.js"],"names":[],"mappings":"AAWA;IAyBE;;;;OAIG;IACH,mBAHW,MAAM,GAAC,UAAU,GAAC,MAAM,GAAC,MAAM,EAAE,GAC/B,IAAI,CAIhB;IA/BD;;;OAGG;IACH,mBAHW,UAAU,EAQpB;IADC,kBAAmC;IAGrC,4BAA4B;IAC5B,cADc,UAAU,CAGvB;IAED;;;OAGG;IACH,WAFa,UAAU,CAItB;CAUF;AAED;IAqDE;;;;;OAKG;IACH,6BAJW,UAAU,QACV,IAAI,GACF,YAAY,CAOxB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GAAC,UAAU,GAAC,MAAM,GAAC,MAAM,EAAE,GAC/B,YAAY,CAIxB;IAxED;;;;OAIG;IACH,mBAHW,UAAU,EAYpB;IALC,kCAAkC;IAClC,cAAmC;IAMrC;;OAEG;IACH,iBAFa,UAAU,CAItB;IAED;;OAEG;IACH,sBAFa,UAAU,CAItB;IAED;;OAEG;IACH,gBAFa,UAAU,CAItB;IAED;;OAEG;IACH,WAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,WAFa,UAAU,CAItB;CAuBF"}
@@ -0,0 +1,19 @@
1
+ export type WalletType = number;
2
+ /**
3
+ * Wallet type enumeration.
4
+ * @module wallet/common/wallettype
5
+ */
6
+ /**
7
+ * @readonly
8
+ * @enum {number}
9
+ */
10
+ export const WalletType: Readonly<{
11
+ SPHINCSPLUS_256S: 0;
12
+ ML_DSA_87: 1;
13
+ }>;
14
+ /**
15
+ * @param {number} t
16
+ * @return {boolean}
17
+ */
18
+ export function isValidWalletType(t: number): boolean;
19
+ //# sourceMappingURL=wallettype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallettype.d.ts","sourceRoot":"","sources":["../../../src/wallet/common/wallettype.js"],"names":[],"mappings":"yBAOU,MAAM;AAPhB;;;GAGG;AAEH;;;GAGG;AACH;;;GAGG;AAEH;;;GAGG;AACH,qCAHW,MAAM,GACL,OAAO,CAIlB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Construct a wallet from an ExtendedSeed by auto-selecting the correct implementation.
3
+ *
4
+ * @param {ExtendedSeed|Uint8Array|string} extendedSeed - ExtendedSeed instance, 51 bytes or hex string.
5
+ * @returns {any} Wallet instance (only ML-DSA-87 for now)
6
+ */
7
+ export function newWalletFromExtendedSeed(extendedSeed: ExtendedSeed | Uint8Array | string): any;
8
+ import { ExtendedSeed } from "./common/seed.js";
9
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/wallet/factory.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wDAHW,YAAY,GAAC,UAAU,GAAC,MAAM,GAC5B,GAAG,CAiBf"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Decode spaced hex mnemonic to bytes.
3
+ * @param {string} mnemonic
4
+ * @returns {Uint8Array}
5
+ */
6
+ export function mnemonicToBin(mnemonic: string): Uint8Array;
7
+ /**
8
+ * Encode bytes to a spaced hex mnemonic string.
9
+ * @param {Uint8Array} input
10
+ * @returns {string}
11
+ */
12
+ export function binToMnemonic(input: Uint8Array): string;
13
+ //# sourceMappingURL=mnemonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.d.ts","sourceRoot":"","sources":["../../../src/wallet/misc/mnemonic.js"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,wCAHW,MAAM,GACJ,UAAU,CAiCtB;AA9DD;;;;GAIG;AACH,qCAHW,UAAU,GACR,MAAM,CAqBlB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generate a keypair.
3
+ * @returns {{ pk: Uint8Array, sk: Uint8Array }}
4
+ */
5
+ export function keygen(seed: any): {
6
+ pk: Uint8Array;
7
+ sk: Uint8Array;
8
+ };
9
+ /**
10
+ * Sign a message.
11
+ * @param {Uint8Array} sk
12
+ * @param {Uint8Array} message
13
+ * @returns {Uint8Array} signature
14
+ */
15
+ export function sign(sk: Uint8Array, message: Uint8Array): Uint8Array;
16
+ /**
17
+ * Verify a signature.
18
+ * @param {Uint8Array} signature
19
+ * @param {Uint8Array} message
20
+ * @param {Uint8Array} pk
21
+ * @returns {boolean}
22
+ */
23
+ export function verify(signature: Uint8Array, message: Uint8Array, pk: Uint8Array): boolean;
24
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/wallet/ml_dsa_87/crypto.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH;QAFmB,UAAU;QAAM,UAAU;EAQ5C;AAED;;;;;GAKG;AACH,yBAJW,UAAU,WACV,UAAU,GACR,UAAU,CAOtB;AAED;;;;;;GAMG;AACH,kCALW,UAAU,WACV,UAAU,MACV,UAAU,GACR,OAAO,CAOnB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * New ML-DSA-87 descriptor with optional 2-byte metadata.
3
+ * @param {[number, number]} [metadata=[0,0]]
4
+ * @returns {Descriptor}
5
+ */
6
+ export function newMLDSA87Descriptor(metadata?: [number, number]): Descriptor;
7
+ import { Descriptor } from "../common/descriptor.js";
8
+ //# sourceMappingURL=descriptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/wallet/ml_dsa_87/descriptor.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,gDAHW,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,UAAU,CAItB"}
@@ -0,0 +1,74 @@
1
+ export type Descriptor = import('../common/descriptor.js').Descriptor;
2
+ export class Wallet {
3
+ /**
4
+ * Create a new random wallet(non-deterministic).
5
+ * @param {[number, number]} [metadata=[0,0] ]
6
+ * @returns {Wallet}
7
+ */
8
+ static newWallet(metadata?: [number, number]): Wallet;
9
+ /**
10
+ * @param {Seed} seed
11
+ * @param {[number, number]} [metadata=[0,0]]
12
+ * @returns {Wallet}
13
+ */
14
+ static newWalletFromSeed(seed: Seed, metadata?: [number, number]): Wallet;
15
+ /**
16
+ * @param {ExtendedSeed} extendedSeed
17
+ * @returns {Wallet}
18
+ */
19
+ static newWalletFromExtendedSeed(extendedSeed: ExtendedSeed): Wallet;
20
+ /**
21
+ * @param {string} mnemonic
22
+ * @returns {Wallet}
23
+ */
24
+ static newWalletFromMnemonic(mnemonic: string): Wallet;
25
+ /**
26
+ * Verify a signature.
27
+ * @param {Uint8Array} signature
28
+ * @param {Uint8Array} message
29
+ * @param {Uint8Array} pk
30
+ * @returns {boolean}
31
+ */
32
+ static verify(signature: Uint8Array, message: Uint8Array, pk: Uint8Array): boolean;
33
+ /**
34
+ * @param {{descriptor: Descriptor, seed: Seed, pk: Uint8Array, sk: Uint8Array}} opts
35
+ */
36
+ constructor({ descriptor, seed, pk, sk }: {
37
+ descriptor: Descriptor;
38
+ seed: Seed;
39
+ pk: Uint8Array;
40
+ sk: Uint8Array;
41
+ });
42
+ descriptor: import("../common/descriptor.js").Descriptor;
43
+ seed: Seed;
44
+ pk: Uint8Array;
45
+ sk: Uint8Array;
46
+ extendedSeed: ExtendedSeed;
47
+ /** @returns {Uint8Array} */
48
+ getAddress(): Uint8Array;
49
+ /** @returns {string} */
50
+ getAddressStr(): string;
51
+ /** @returns {Descriptor} */
52
+ getDescriptor(): Descriptor;
53
+ /** @returns {ExtendedSeed} */
54
+ getExtendedSeed(): ExtendedSeed;
55
+ /** @returns {Seed} */
56
+ getSeed(): Seed;
57
+ /** @returns {string} hex(ExtendedSeed) */
58
+ getHexExtendedSeed(): string;
59
+ /** @returns {string} */
60
+ getMnemonic(): string;
61
+ /** @returns {Uint8Array} */
62
+ getPK(): Uint8Array;
63
+ /** @returns {Uint8Array} */
64
+ getSK(): Uint8Array;
65
+ /**
66
+ * Sign a message.
67
+ * @param {Uint8Array} message
68
+ * @returns {Uint8Array} Signature bytes.
69
+ */
70
+ sign(message: Uint8Array): Uint8Array;
71
+ }
72
+ import { Seed } from "../common/seed.js";
73
+ import { ExtendedSeed } from "../common/seed.js";
74
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallet/ml_dsa_87/wallet.js"],"names":[],"mappings":"yBAKc,OAAO,yBAAyB,EAAE,UAAU;AAS1D;IAYE;;;;OAIG;IACH,4BAHW,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,MAAM,CAQlB;IAED;;;;OAIG;IACH,+BAJW,IAAI,aACJ,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,MAAM,CAMlB;IAED;;;OAGG;IACH,+CAHW,YAAY,GACV,MAAM,CAOlB;IAED;;;OAGG;IACH,uCAHW,MAAM,GACJ,MAAM,CAMlB;IAwDD;;;;;;OAMG;IACH,yBALW,UAAU,WACV,UAAU,MACV,UAAU,GACR,OAAO,CAInB;IAvHD;;OAEG;IACH,0CAFW;QAAC,UAAU,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,IAAI,CAAC;QAAC,EAAE,EAAE,UAAU,CAAC;QAAC,EAAE,EAAE,UAAU,CAAA;KAAC,EAQ9E;IALC,yDAA4B;IAC5B,WAAgB;IAChB,eAAY;IACZ,eAAY;IACZ,2BAAkE;IAgDpE,4BAA4B;IAC5B,cADc,UAAU,CAGvB;IAED,wBAAwB;IACxB,iBADc,MAAM,CAGnB;IAED,4BAA4B;IAC5B,iBADc,UAAU,CAGvB;IAED,8BAA8B;IAC9B,mBADc,YAAY,CAGzB;IAED,sBAAsB;IACtB,WADc,IAAI,CAGjB;IAED,0CAA0C;IAC1C,sBADc,MAAM,CAGnB;IAED,wBAAwB;IACxB,eADc,MAAM,CAGnB;IAED,4BAA4B;IAC5B,SADc,UAAU,CAGvB;IAED,4BAA4B;IAC5B,SADc,UAAU,CAGvB;IAED;;;;OAIG;IACH,cAHW,UAAU,GACR,UAAU,CAItB;CAYF"}