@xyo-network/quant-wallet 6.0.3

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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @xyo-network/quant-wallet
2
+
3
+ Quantum-resistant HD Wallet that implements `WalletInstance` using **ML-DSA-65** (FIPS 204) signing and **BIP-85** entropy derivation.
4
+
5
+ A classical BIP-32/BIP-39 spine (via `ethers.HDNodeWallet`) walks the hierarchy; at every node, BIP-85 derives a deterministic 32-byte seed (`HMAC-SHA512("bip-entropy-from-k", node.privateKey)[0..32]`) that becomes the input to `MlDsa.keygen(seed)`. The result is a deterministic, hierarchical post-quantum identity reproducible from a single BIP-39 mnemonic.
6
+
7
+ Addresses are prefixed with `qr1_` so the BoundWitness validator dispatches to the ML-DSA verifier registered by `@xyo-network/quant-account`.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { QuantHDWallet } from '@xyo-network/quant-wallet'
13
+
14
+ const wallet = await QuantHDWallet.fromPhrase('abandon abandon ... abandon abandon about')
15
+ console.log(wallet.address) // 'qr1_<40 hex chars>'
16
+ console.log(wallet.algorithm) // 'ml-dsa-65'
17
+
18
+ const child = await wallet.derivePath("m/44'/60'/0'/0/0")
19
+ const [signature] = await child.sign(hashBytes)
20
+ ```
21
+
22
+ ## Notes
23
+
24
+ - `derivePath` accepts either a classical BIP-32 path (entropy comes from the implicit BIP-85 leaf tail) or an explicit BIP-85 path beginning with `m/83696968'/`.
25
+ - `neuter()` is not supported — ML-DSA-65 has no standardized public-key-only HD derivation.
26
+ - `signJwt` is not implemented — no IANA JOSE `alg` for ML-DSA-65 is finalized yet.
@@ -0,0 +1,46 @@
1
+ import type { Address, Hash, Hex } from '@xylabs/sdk-js';
2
+ import type { AccountAlgorithm, AccountConfig, AccountInstance, SignJwtOptions, SignJwtResult } from '@xyo-network/account-model';
3
+ import type { WalletInstance } from '@xyo-network/wallet-model';
4
+ import { HDNodeWallet, Mnemonic } from 'ethers';
5
+ export declare class QuantHDWallet implements WalletInstance {
6
+ private static _protectedConstructorKey;
7
+ private static _walletAddressMap;
8
+ readonly algorithm: AccountAlgorithm;
9
+ protected readonly _account: AccountInstance;
10
+ protected readonly _master: HDNodeWallet | undefined;
11
+ protected readonly _seed: Uint8Array;
12
+ protected readonly node: HDNodeWallet;
13
+ protected constructor(key: unknown, node: HDNodeWallet, master: HDNodeWallet | undefined, seed: Uint8Array, account: AccountInstance);
14
+ get address(): Address;
15
+ get addressBytes(): ArrayBufferLike;
16
+ get chainCode(): string;
17
+ get depth(): number;
18
+ get extendedKey(): string;
19
+ get fingerprint(): string;
20
+ get index(): number;
21
+ get mnemonic(): Mnemonic | null;
22
+ get parentFingerprint(): string;
23
+ get path(): string | null;
24
+ get previousHash(): Hash | undefined;
25
+ set previousHash(_value: Hash | undefined);
26
+ get previousHashBytes(): ArrayBufferLike | undefined;
27
+ set previousHashBytes(_value: ArrayBufferLike | undefined);
28
+ get privateKey(): Hex;
29
+ get publicKey(): Hex;
30
+ static create(opts?: AccountConfig): Promise<WalletInstance>;
31
+ static fromExtendedKey(key: string): Promise<WalletInstance>;
32
+ static fromMnemonic(mnemonic: Mnemonic, path?: string): Promise<WalletInstance>;
33
+ static fromPhrase(phrase: string, path?: string): Promise<WalletInstance>;
34
+ static fromPrivateKey(_key: ArrayBufferLike | bigint | string): Promise<AccountInstance>;
35
+ static fromSeed(seed: string | ArrayBufferLike): Promise<WalletInstance>;
36
+ static generateMnemonic(wordlist?: string[], strength?: number): string;
37
+ static random(): Promise<WalletInstance>;
38
+ protected static createFromNode(node: HDNodeWallet, master?: HDNodeWallet, previousHash?: string): Promise<WalletInstance>;
39
+ derivePath(path: string): Promise<WalletInstance>;
40
+ neuter: () => WalletInstance;
41
+ sign(hash: ArrayBufferLike, previousHash?: ArrayBufferLike): Promise<[ArrayBufferLike, Hash?]>;
42
+ signJwt(options: SignJwtOptions): Promise<SignJwtResult>;
43
+ verify(msg: ArrayBufferLike, signature: ArrayBufferLike): Promise<boolean>;
44
+ verifyUniqueWallet(): WalletInstance;
45
+ }
46
+ //# sourceMappingURL=QuantHDWallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuantHDWallet.d.ts","source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AI,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;IAI9F,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAIxD,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhF,kBAAkB,IAAI,cAAc;CASrC"}
@@ -0,0 +1,10 @@
1
+ import type { HDNodeWallet } from 'ethers';
2
+ export declare const BIP85_PURPOSE = "83696968'";
3
+ export declare const BIP85_HEX_APP = "128169'";
4
+ export declare const BIP85_HMAC_KEY = "bip-entropy-from-k";
5
+ export declare const BIP85_SEED_LENGTH = 32;
6
+ export declare function bip85DefaultLeafTail(index?: number): string;
7
+ export declare function isBip85AbsolutePath(path: string): boolean;
8
+ export declare function isUnderBip85Purpose(node: HDNodeWallet): boolean;
9
+ export declare function bip85EntropyFromNode(node: HDNodeWallet): Uint8Array;
10
+ //# sourceMappingURL=bip85.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip85.d.ts","sourceRoot":"","sources":["../../src/bip85.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAK1C,eAAO,MAAM,aAAa,cAAc,CAAA;AACxC,eAAO,MAAM,aAAa,YAAY,CAAA;AACtC,eAAO,MAAM,cAAc,uBAAuB,CAAA;AAClD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,wBAAgB,oBAAoB,CAAC,KAAK,SAAI,GAAG,MAAM,CAEtD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAI/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAKnE"}
@@ -0,0 +1,3 @@
1
+ export * from './bip85.ts';
2
+ export * from './QuantHDWallet.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,230 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
+
14
+ // src/bip85.ts
15
+ import {
16
+ computeHmac,
17
+ getBytes,
18
+ toUtf8Bytes
19
+ } from "ethers";
20
+ var BIP85_PURPOSE = "83696968'";
21
+ var BIP85_HEX_APP = "128169'";
22
+ var BIP85_HMAC_KEY = "bip-entropy-from-k";
23
+ var BIP85_SEED_LENGTH = 32;
24
+ function bip85DefaultLeafTail(index = 0) {
25
+ return `${BIP85_PURPOSE}/${BIP85_HEX_APP}/32'/${index}'`;
26
+ }
27
+ function isBip85AbsolutePath(path) {
28
+ return path.startsWith(`m/${BIP85_PURPOSE}/`);
29
+ }
30
+ function isUnderBip85Purpose(node) {
31
+ const p = node.path;
32
+ if (p === null) return false;
33
+ return p === `m/${BIP85_PURPOSE}` || p.startsWith(`m/${BIP85_PURPOSE}/`);
34
+ }
35
+ function bip85EntropyFromNode(node) {
36
+ const key = toUtf8Bytes(BIP85_HMAC_KEY);
37
+ const msg = getBytes(node.privateKey);
38
+ const hmac = computeHmac("sha512", key, msg);
39
+ return getBytes(hmac).slice(0, BIP85_SEED_LENGTH);
40
+ }
41
+
42
+ // src/QuantHDWallet.ts
43
+ import { generateMnemonic } from "@scure/bip39";
44
+ import { wordlist as englishWordlist } from "@scure/bip39/wordlists/english.js";
45
+ import {
46
+ hexFromArrayBuffer,
47
+ staticImplements,
48
+ toUint8Array
49
+ } from "@xylabs/sdk-js";
50
+ import {
51
+ isMnemonicInitializationConfig,
52
+ isPhraseInitializationConfig,
53
+ isPrivateKeyInitializationConfig
54
+ } from "@xyo-network/account-model";
55
+ import { QuantAccount } from "@xyo-network/quant-account";
56
+ import {
57
+ defaultPath,
58
+ HDNodeWallet,
59
+ Mnemonic
60
+ } from "ethers";
61
+ var QuantHDWallet = class {
62
+ algorithm = "ml-dsa-65";
63
+ _account;
64
+ _master;
65
+ _seed;
66
+ node;
67
+ constructor(key, node, master, seed, account) {
68
+ if (key !== QuantHDWallet._protectedConstructorKey) {
69
+ throw new Error("Do not call this protected constructor");
70
+ }
71
+ this.node = node;
72
+ this._master = master;
73
+ this._seed = seed;
74
+ this._account = account;
75
+ }
76
+ get address() {
77
+ return this._account.address;
78
+ }
79
+ get addressBytes() {
80
+ return this._account.addressBytes;
81
+ }
82
+ get chainCode() {
83
+ return this.node.chainCode;
84
+ }
85
+ get depth() {
86
+ return this.node.depth;
87
+ }
88
+ get extendedKey() {
89
+ return this.node.extendedKey;
90
+ }
91
+ get fingerprint() {
92
+ return this.node.fingerprint;
93
+ }
94
+ get index() {
95
+ return this.node.index;
96
+ }
97
+ get mnemonic() {
98
+ return this.node.mnemonic;
99
+ }
100
+ get parentFingerprint() {
101
+ return this.node.parentFingerprint;
102
+ }
103
+ get path() {
104
+ return this.node.path;
105
+ }
106
+ get previousHash() {
107
+ return this._account.previousHash;
108
+ }
109
+ set previousHash(_value) {
110
+ }
111
+ get previousHashBytes() {
112
+ return this._account.previousHashBytes;
113
+ }
114
+ set previousHashBytes(_value) {
115
+ }
116
+ get privateKey() {
117
+ return hexFromArrayBuffer(this._seed.buffer, { prefix: false }).toLowerCase();
118
+ }
119
+ get publicKey() {
120
+ const bytes = this._account.publicKey;
121
+ return hexFromArrayBuffer(bytes, { prefix: false }).toLowerCase();
122
+ }
123
+ static async create(opts) {
124
+ if (isPhraseInitializationConfig(opts)) {
125
+ return await this.fromPhrase(opts.phrase);
126
+ }
127
+ if (isMnemonicInitializationConfig(opts)) {
128
+ return await this.fromPhrase(opts.mnemonic, opts.path);
129
+ }
130
+ if (isPrivateKeyInitializationConfig(opts)) {
131
+ throw new Error("Invalid initialization config. from privateKey not supported. Use QuantAccount.fromPrivateKey instead.");
132
+ }
133
+ throw new Error("Invalid initialization config");
134
+ }
135
+ static async fromExtendedKey(key) {
136
+ const node = HDNodeWallet.fromExtendedKey(key);
137
+ const master = node.depth === 0 ? node : void 0;
138
+ return await this.createFromNode(node, master);
139
+ }
140
+ static async fromMnemonic(mnemonic, path = defaultPath) {
141
+ const master = HDNodeWallet.fromMnemonic(mnemonic, "m");
142
+ const node = path === "m" || path === "m/" ? master : master.derivePath(path.startsWith("m/") ? path.slice(2) : path);
143
+ return await this.createFromNode(node, master);
144
+ }
145
+ static async fromPhrase(phrase, path = defaultPath) {
146
+ return await this.fromMnemonic(Mnemonic.fromPhrase(phrase), path);
147
+ }
148
+ static async fromPrivateKey(_key) {
149
+ return await Promise.reject(new Error("fromPrivateKey is not supported on QuantHDWallet \u2014 use fromSeed, fromPhrase, fromMnemonic, or fromExtendedKey"));
150
+ }
151
+ static async fromSeed(seed) {
152
+ const master = HDNodeWallet.fromSeed(toUint8Array(seed));
153
+ return await this.createFromNode(master, master);
154
+ }
155
+ static generateMnemonic(wordlist = englishWordlist, strength = 256) {
156
+ return generateMnemonic(wordlist, strength);
157
+ }
158
+ static async random() {
159
+ return await this.fromPhrase(QuantHDWallet.generateMnemonic());
160
+ }
161
+ static async createFromNode(node, master, previousHash) {
162
+ const leafNode = isUnderBip85Purpose(node) ? node : node.derivePath(bip85DefaultLeafTail(0));
163
+ const seed = bip85EntropyFromNode(leafNode);
164
+ const account = await QuantAccount.create({
165
+ privateKey: seed.buffer,
166
+ previousHash: previousHash === void 0 ? void 0 : toUint8Array(previousHash, 32).buffer
167
+ });
168
+ const wallet = new QuantHDWallet(QuantHDWallet._protectedConstructorKey, node, master, seed, account);
169
+ return wallet.verifyUniqueWallet();
170
+ }
171
+ async derivePath(path) {
172
+ if (path.startsWith("m/")) {
173
+ if (isBip85AbsolutePath(path)) {
174
+ if (this._master === void 0) {
175
+ throw new Error("Cannot derive BIP-85 absolute path: wallet has no master node (built from extended key)");
176
+ }
177
+ const childNode = this._master.derivePath(path.slice(2));
178
+ return await QuantHDWallet.createFromNode(childNode, this._master);
179
+ }
180
+ const parentPath = this.path;
181
+ if (parentPath !== null && path.startsWith(parentPath)) {
182
+ const childPath = path.slice(parentPath.length + 1);
183
+ return await QuantHDWallet.createFromNode(this.node.derivePath(childPath), this._master);
184
+ }
185
+ if (this._master !== void 0) {
186
+ return await QuantHDWallet.createFromNode(this._master.derivePath(path.slice(2)), this._master);
187
+ }
188
+ throw new Error(`Invalid absolute path ${path} for wallet with path ${parentPath}`);
189
+ }
190
+ return await QuantHDWallet.createFromNode(this.node.derivePath(path), this._master);
191
+ }
192
+ neuter = () => {
193
+ throw new Error("neuter() is not implemented for ml-dsa-65 HD wallets");
194
+ };
195
+ async sign(hash, previousHash) {
196
+ return await this._account.sign(hash, previousHash);
197
+ }
198
+ async signJwt(options) {
199
+ return await this._account.signJwt(options);
200
+ }
201
+ async verify(msg, signature) {
202
+ return await this._account.verify(msg, signature);
203
+ }
204
+ verifyUniqueWallet() {
205
+ const address = this.address;
206
+ const existing = QuantHDWallet._walletAddressMap[address]?.deref();
207
+ if (existing === void 0) {
208
+ QuantHDWallet._walletAddressMap[address] = new WeakRef(this);
209
+ return this;
210
+ }
211
+ return existing;
212
+ }
213
+ };
214
+ __publicField(QuantHDWallet, "_protectedConstructorKey", /* @__PURE__ */ Symbol());
215
+ __publicField(QuantHDWallet, "_walletAddressMap", {});
216
+ QuantHDWallet = __decorateClass([
217
+ staticImplements()
218
+ ], QuantHDWallet);
219
+ export {
220
+ BIP85_HEX_APP,
221
+ BIP85_HMAC_KEY,
222
+ BIP85_PURPOSE,
223
+ BIP85_SEED_LENGTH,
224
+ QuantHDWallet,
225
+ bip85DefaultLeafTail,
226
+ bip85EntropyFromNode,
227
+ isBip85AbsolutePath,
228
+ isUnderBip85Purpose
229
+ };
230
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/bip85.ts", "../../src/QuantHDWallet.ts"],
4
+ "sourcesContent": ["import type { HDNodeWallet } from 'ethers'\nimport {\n computeHmac, getBytes, toUtf8Bytes,\n} from 'ethers'\n\nexport const BIP85_PURPOSE = \"83696968'\"\nexport const BIP85_HEX_APP = \"128169'\"\nexport const BIP85_HMAC_KEY = 'bip-entropy-from-k'\nexport const BIP85_SEED_LENGTH = 32\n\nexport function bip85DefaultLeafTail(index = 0): string {\n return `${BIP85_PURPOSE}/${BIP85_HEX_APP}/32'/${index}'`\n}\n\nexport function isBip85AbsolutePath(path: string): boolean {\n return path.startsWith(`m/${BIP85_PURPOSE}/`)\n}\n\nexport function isUnderBip85Purpose(node: HDNodeWallet): boolean {\n const p = node.path\n if (p === null) return false\n return p === `m/${BIP85_PURPOSE}` || p.startsWith(`m/${BIP85_PURPOSE}/`)\n}\n\nexport function bip85EntropyFromNode(node: HDNodeWallet): Uint8Array {\n const key = toUtf8Bytes(BIP85_HMAC_KEY)\n const msg = getBytes(node.privateKey)\n const hmac = computeHmac('sha512', key, msg)\n return getBytes(hmac).slice(0, BIP85_SEED_LENGTH)\n}\n", "import { generateMnemonic } from '@scure/bip39'\nimport { wordlist as englishWordlist } from '@scure/bip39/wordlists/english.js'\nimport type {\n Address, Hash, Hex,\n} from '@xylabs/sdk-js'\nimport {\n hexFromArrayBuffer, staticImplements, toUint8Array,\n} from '@xylabs/sdk-js'\nimport type {\n AccountAlgorithm,\n AccountConfig, AccountInstance, SignJwtOptions, SignJwtResult,\n} from '@xyo-network/account-model'\nimport {\n isMnemonicInitializationConfig,\n isPhraseInitializationConfig,\n isPrivateKeyInitializationConfig,\n} from '@xyo-network/account-model'\nimport { QuantAccount } from '@xyo-network/quant-account'\nimport type { WalletInstance, WalletStatic } from '@xyo-network/wallet-model'\nimport {\n defaultPath, HDNodeWallet, Mnemonic,\n} from 'ethers'\n\nimport {\n bip85DefaultLeafTail,\n bip85EntropyFromNode,\n isBip85AbsolutePath,\n isUnderBip85Purpose,\n} from './bip85.ts'\n\n@staticImplements<WalletStatic<WalletInstance>>()\nexport class QuantHDWallet implements WalletInstance {\n private static _protectedConstructorKey = Symbol()\n private static _walletAddressMap: Record<string, WeakRef<WalletInstance>> = {}\n\n readonly algorithm: AccountAlgorithm = 'ml-dsa-65'\n\n protected readonly _account: AccountInstance\n protected readonly _master: HDNodeWallet | undefined\n protected readonly _seed: Uint8Array\n protected readonly node: HDNodeWallet\n\n protected constructor(\n key: unknown,\n node: HDNodeWallet,\n master: HDNodeWallet | undefined,\n seed: Uint8Array,\n account: AccountInstance,\n ) {\n if (key !== QuantHDWallet._protectedConstructorKey) {\n throw new Error('Do not call this protected constructor')\n }\n this.node = node\n this._master = master\n this._seed = seed\n this._account = account\n }\n\n get address(): Address {\n return this._account.address\n }\n\n get addressBytes(): ArrayBufferLike {\n return this._account.addressBytes\n }\n\n get chainCode(): string {\n return this.node.chainCode\n }\n\n get depth(): number {\n return this.node.depth\n }\n\n get extendedKey(): string {\n return this.node.extendedKey\n }\n\n get fingerprint(): string {\n return this.node.fingerprint\n }\n\n get index(): number {\n return this.node.index\n }\n\n get mnemonic(): Mnemonic | null {\n return this.node.mnemonic\n }\n\n get parentFingerprint(): string {\n return this.node.parentFingerprint\n }\n\n get path(): string | null {\n return this.node.path\n }\n\n get previousHash(): Hash | undefined {\n return this._account.previousHash\n }\n\n set previousHash(_value: Hash | undefined) {\n // intentionally not supported \u2014 use sign() chaining\n }\n\n get previousHashBytes(): ArrayBufferLike | undefined {\n return this._account.previousHashBytes\n }\n\n set previousHashBytes(_value: ArrayBufferLike | undefined) {\n // intentionally not supported \u2014 use sign() chaining\n }\n\n get privateKey(): Hex {\n return hexFromArrayBuffer(this._seed.buffer, { prefix: false }).toLowerCase() as Hex\n }\n\n get publicKey(): Hex {\n const bytes = (this._account as unknown as { publicKey: ArrayBufferLike }).publicKey\n return hexFromArrayBuffer(bytes, { prefix: false }).toLowerCase() as Hex\n }\n\n static async create(opts?: AccountConfig): Promise<WalletInstance> {\n if (isPhraseInitializationConfig(opts)) {\n return await this.fromPhrase(opts.phrase)\n }\n if (isMnemonicInitializationConfig(opts)) {\n return await this.fromPhrase(opts.mnemonic, opts.path)\n }\n if (isPrivateKeyInitializationConfig(opts)) {\n throw new Error('Invalid initialization config. from privateKey not supported. Use QuantAccount.fromPrivateKey instead.')\n }\n throw new Error('Invalid initialization config')\n }\n\n static async fromExtendedKey(key: string): Promise<WalletInstance> {\n const node = HDNodeWallet.fromExtendedKey(key) as HDNodeWallet\n // If the xkey is the root (depth 0), it is its own master and absolute BIP-85 paths can be resolved\n const master = node.depth === 0 ? node : undefined\n return await this.createFromNode(node, master)\n }\n\n static async fromMnemonic(mnemonic: Mnemonic, path: string = defaultPath): Promise<WalletInstance> {\n // Pass 'm' explicitly: without it, ethers returns the node at defaultPath rather than the BIP-32 root.\n const master = HDNodeWallet.fromMnemonic(mnemonic, 'm')\n const node = path === 'm' || path === 'm/' ? master : master.derivePath(path.startsWith('m/') ? path.slice(2) : path)\n return await this.createFromNode(node, master)\n }\n\n static async fromPhrase(phrase: string, path: string = defaultPath): Promise<WalletInstance> {\n return await this.fromMnemonic(Mnemonic.fromPhrase(phrase), path)\n }\n\n static async fromPrivateKey(_key: ArrayBufferLike | bigint | string): Promise<AccountInstance> {\n return await Promise.reject(new Error('fromPrivateKey is not supported on QuantHDWallet \u2014 use fromSeed, fromPhrase, fromMnemonic, or fromExtendedKey'))\n }\n\n static async fromSeed(seed: string | ArrayBufferLike): Promise<WalletInstance> {\n const master = HDNodeWallet.fromSeed(toUint8Array(seed))\n return await this.createFromNode(master, master)\n }\n\n static generateMnemonic(wordlist: string[] = englishWordlist, strength = 256): string {\n return generateMnemonic(wordlist, strength)\n }\n\n static async random(): Promise<WalletInstance> {\n return await this.fromPhrase(QuantHDWallet.generateMnemonic())\n }\n\n protected static async createFromNode(\n node: HDNodeWallet,\n master?: HDNodeWallet,\n previousHash?: string,\n ): Promise<WalletInstance> {\n // If the node is already under the BIP-85 purpose subtree, take entropy right there.\n // Otherwise auto-descend to the default HEX-entropy leaf (num_bytes=32, index=0).\n const leafNode = isUnderBip85Purpose(node) ? node : node.derivePath(bip85DefaultLeafTail(0))\n const seed = bip85EntropyFromNode(leafNode)\n const account = await QuantAccount.create({\n privateKey: seed.buffer,\n previousHash: previousHash === undefined ? undefined : toUint8Array(previousHash, 32).buffer,\n })\n const wallet = new QuantHDWallet(QuantHDWallet._protectedConstructorKey, node, master, seed, account)\n return wallet.verifyUniqueWallet()\n }\n\n async derivePath(path: string): Promise<WalletInstance> {\n if (path.startsWith('m/')) {\n if (isBip85AbsolutePath(path)) {\n if (this._master === undefined) {\n throw new Error('Cannot derive BIP-85 absolute path: wallet has no master node (built from extended key)')\n }\n const childNode = this._master.derivePath(path.slice(2))\n return await QuantHDWallet.createFromNode(childNode, this._master)\n }\n const parentPath = this.path\n if (parentPath !== null && path.startsWith(parentPath)) {\n const childPath = path.slice(parentPath.length + 1)\n return await QuantHDWallet.createFromNode(this.node.derivePath(childPath), this._master)\n }\n if (this._master !== undefined) {\n return await QuantHDWallet.createFromNode(this._master.derivePath(path.slice(2)), this._master)\n }\n throw new Error(`Invalid absolute path ${path} for wallet with path ${parentPath}`)\n }\n return await QuantHDWallet.createFromNode(this.node.derivePath(path), this._master)\n }\n\n neuter: () => WalletInstance = () => {\n throw new Error('neuter() is not implemented for ml-dsa-65 HD wallets')\n }\n\n async sign(hash: ArrayBufferLike, previousHash?: ArrayBufferLike): Promise<[ArrayBufferLike, Hash?]> {\n return await this._account.sign(hash, previousHash)\n }\n\n async signJwt(options: SignJwtOptions): Promise<SignJwtResult> {\n return await this._account.signJwt(options)\n }\n\n async verify(msg: ArrayBufferLike, signature: ArrayBufferLike): Promise<boolean> {\n return await this._account.verify(msg, signature)\n }\n\n verifyUniqueWallet(): WalletInstance {\n const address = this.address\n const existing = QuantHDWallet._walletAddressMap[address]?.deref()\n if (existing === undefined) {\n QuantHDWallet._walletAddressMap[address] = new WeakRef<WalletInstance>(this)\n return this\n }\n return existing\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EAAa;AAAA,EAAU;AAAA,OAClB;AAEA,IAAM,gBAAgB;AACtB,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAE1B,SAAS,qBAAqB,QAAQ,GAAW;AACtD,SAAO,GAAG,aAAa,IAAI,aAAa,QAAQ,KAAK;AACvD;AAEO,SAAS,oBAAoB,MAAuB;AACzD,SAAO,KAAK,WAAW,KAAK,aAAa,GAAG;AAC9C;AAEO,SAAS,oBAAoB,MAA6B;AAC/D,QAAM,IAAI,KAAK;AACf,MAAI,MAAM,KAAM,QAAO;AACvB,SAAO,MAAM,KAAK,aAAa,MAAM,EAAE,WAAW,KAAK,aAAa,GAAG;AACzE;AAEO,SAAS,qBAAqB,MAAgC;AACnE,QAAM,MAAM,YAAY,cAAc;AACtC,QAAM,MAAM,SAAS,KAAK,UAAU;AACpC,QAAM,OAAO,YAAY,UAAU,KAAK,GAAG;AAC3C,SAAO,SAAS,IAAI,EAAE,MAAM,GAAG,iBAAiB;AAClD;;;AC7BA,SAAS,wBAAwB;AACjC,SAAS,YAAY,uBAAuB;AAI5C;AAAA,EACE;AAAA,EAAoB;AAAA,EAAkB;AAAA,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AAG,KAAK,OAAO;AAAA,MACzF;AACA,UAAI,KAAK,YAAY,QAAW;AAC9B,eAAO,MAAM,cAAc,eAAe,KAAK,QAAQ,WAAW,KAAK,MAAM,CAAC,CAAC,GAAG,KAAK,OAAO;AAAA,MAChG;AACA,YAAM,IAAI,MAAM,yBAAyB,IAAI,yBAAyB,UAAU,EAAE;AAAA,IACpF;AACA,WAAO,MAAM,cAAc,eAAe,KAAK,KAAK,WAAW,IAAI,GAAG,KAAK,OAAO;AAAA,EACpF;AAAA,EAEA,SAA+B,MAAM;AACnC,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AAAA,EAEA,MAAM,KAAK,MAAuB,cAAmE;AACnG,WAAO,MAAM,KAAK,SAAS,KAAK,MAAM,YAAY;AAAA,EACpD;AAAA,EAEA,MAAM,QAAQ,SAAiD;AAC7D,WAAO,MAAM,KAAK,SAAS,QAAQ,OAAO;AAAA,EAC5C;AAAA,EAEA,MAAM,OAAO,KAAsB,WAA8C;AAC/E,WAAO,MAAM,KAAK,SAAS,OAAO,KAAK,SAAS;AAAA,EAClD;AAAA,EAEA,qBAAqC;AACnC,UAAM,UAAU,KAAK;AACrB,UAAM,WAAW,cAAc,kBAAkB,OAAO,GAAG,MAAM;AACjE,QAAI,aAAa,QAAW;AAC1B,oBAAc,kBAAkB,OAAO,IAAI,IAAI,QAAwB,IAAI;AAC3E,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;AA3ME,cADW,eACI,4BAA2B,uBAAO;AACjD,cAFW,eAEI,qBAA6D,CAAC;AAFlE,gBAAN;AAAA,EADN,iBAA+C;AAAA,GACnC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,46 @@
1
+ import type { Address, Hash, Hex } from '@xylabs/sdk-js';
2
+ import type { AccountAlgorithm, AccountConfig, AccountInstance, SignJwtOptions, SignJwtResult } from '@xyo-network/account-model';
3
+ import type { WalletInstance } from '@xyo-network/wallet-model';
4
+ import { HDNodeWallet, Mnemonic } from 'ethers';
5
+ export declare class QuantHDWallet implements WalletInstance {
6
+ private static _protectedConstructorKey;
7
+ private static _walletAddressMap;
8
+ readonly algorithm: AccountAlgorithm;
9
+ protected readonly _account: AccountInstance;
10
+ protected readonly _master: HDNodeWallet | undefined;
11
+ protected readonly _seed: Uint8Array;
12
+ protected readonly node: HDNodeWallet;
13
+ protected constructor(key: unknown, node: HDNodeWallet, master: HDNodeWallet | undefined, seed: Uint8Array, account: AccountInstance);
14
+ get address(): Address;
15
+ get addressBytes(): ArrayBufferLike;
16
+ get chainCode(): string;
17
+ get depth(): number;
18
+ get extendedKey(): string;
19
+ get fingerprint(): string;
20
+ get index(): number;
21
+ get mnemonic(): Mnemonic | null;
22
+ get parentFingerprint(): string;
23
+ get path(): string | null;
24
+ get previousHash(): Hash | undefined;
25
+ set previousHash(_value: Hash | undefined);
26
+ get previousHashBytes(): ArrayBufferLike | undefined;
27
+ set previousHashBytes(_value: ArrayBufferLike | undefined);
28
+ get privateKey(): Hex;
29
+ get publicKey(): Hex;
30
+ static create(opts?: AccountConfig): Promise<WalletInstance>;
31
+ static fromExtendedKey(key: string): Promise<WalletInstance>;
32
+ static fromMnemonic(mnemonic: Mnemonic, path?: string): Promise<WalletInstance>;
33
+ static fromPhrase(phrase: string, path?: string): Promise<WalletInstance>;
34
+ static fromPrivateKey(_key: ArrayBufferLike | bigint | string): Promise<AccountInstance>;
35
+ static fromSeed(seed: string | ArrayBufferLike): Promise<WalletInstance>;
36
+ static generateMnemonic(wordlist?: string[], strength?: number): string;
37
+ static random(): Promise<WalletInstance>;
38
+ protected static createFromNode(node: HDNodeWallet, master?: HDNodeWallet, previousHash?: string): Promise<WalletInstance>;
39
+ derivePath(path: string): Promise<WalletInstance>;
40
+ neuter: () => WalletInstance;
41
+ sign(hash: ArrayBufferLike, previousHash?: ArrayBufferLike): Promise<[ArrayBufferLike, Hash?]>;
42
+ signJwt(options: SignJwtOptions): Promise<SignJwtResult>;
43
+ verify(msg: ArrayBufferLike, signature: ArrayBufferLike): Promise<boolean>;
44
+ verifyUniqueWallet(): WalletInstance;
45
+ }
46
+ //# sourceMappingURL=QuantHDWallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuantHDWallet.d.ts","sourceRoot":"","sources":["../../src/QuantHDWallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,GAAG,EACnB,MAAM,gBAAgB,CAAA;AAIvB,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAC9D,MAAM,4BAA4B,CAAA;AAOnC,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EACQ,YAAY,EAAE,QAAQ,EACpC,MAAM,QAAQ,CAAA;AASf,qBACa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAW;IAClD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA8C;IAE9E,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAc;IAElD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;IAC5C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAAA;IACpD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IACpC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAErC,SAAS,aACP,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,eAAe;IAW1B,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,YAAY,IAAI,eAAe,CAElC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IA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,CAAC,cAAc,CAAC;IAapB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAsBvD,MAAM,EAAE,MAAM,cAAc,CAE3B;IAEK,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;IAI9F,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAIxD,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhF,kBAAkB,IAAI,cAAc;CASrC"}
@@ -0,0 +1,10 @@
1
+ import type { HDNodeWallet } from 'ethers';
2
+ export declare const BIP85_PURPOSE = "83696968'";
3
+ export declare const BIP85_HEX_APP = "128169'";
4
+ export declare const BIP85_HMAC_KEY = "bip-entropy-from-k";
5
+ export declare const BIP85_SEED_LENGTH = 32;
6
+ export declare function bip85DefaultLeafTail(index?: number): string;
7
+ export declare function isBip85AbsolutePath(path: string): boolean;
8
+ export declare function isUnderBip85Purpose(node: HDNodeWallet): boolean;
9
+ export declare function bip85EntropyFromNode(node: HDNodeWallet): Uint8Array;
10
+ //# sourceMappingURL=bip85.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip85.d.ts","sourceRoot":"","sources":["../../src/bip85.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAK1C,eAAO,MAAM,aAAa,cAAc,CAAA;AACxC,eAAO,MAAM,aAAa,YAAY,CAAA;AACtC,eAAO,MAAM,cAAc,uBAAuB,CAAA;AAClD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,wBAAgB,oBAAoB,CAAC,KAAK,SAAI,GAAG,MAAM,CAEtD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAI/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAKnE"}
@@ -0,0 +1,3 @@
1
+ export * from './bip85.ts';
2
+ export * from './QuantHDWallet.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA"}