@unlink-xyz/core 0.1.3-canary.455d0fd → 0.1.3-canary.52b60f9
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/account/{account.d.ts → zkAccount.d.ts} +4 -6
- package/dist/account/zkAccount.d.ts.map +1 -0
- package/dist/account/{account.js → zkAccount.js} +10 -32
- package/dist/clients/http.d.ts +0 -6
- package/dist/clients/http.d.ts.map +1 -1
- package/dist/clients/http.js +0 -8
- package/dist/clients/indexer.d.ts +0 -1
- package/dist/clients/indexer.d.ts.map +1 -1
- package/dist/clients/indexer.js +0 -1
- package/dist/config.d.ts +9 -31
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -29
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +0 -2
- package/dist/index.d.ts +4 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -8
- package/dist/key-derivation/babyjubjub.d.ts +9 -0
- package/dist/key-derivation/babyjubjub.d.ts.map +1 -0
- package/dist/key-derivation/babyjubjub.js +9 -0
- package/dist/key-derivation/bip39.d.ts.map +1 -1
- package/dist/key-derivation/bip39.js +0 -1
- package/dist/key-derivation/index.d.ts +1 -0
- package/dist/key-derivation/index.d.ts.map +1 -1
- package/dist/key-derivation/index.js +1 -0
- package/dist/key-derivation/wallet-node.d.ts +1 -3
- package/dist/key-derivation/wallet-node.d.ts.map +1 -1
- package/dist/key-derivation/wallet-node.js +4 -5
- package/dist/keys.d.ts +1 -4
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +0 -4
- package/dist/prover/config.d.ts +15 -1
- package/dist/prover/config.d.ts.map +1 -1
- package/dist/prover/config.js +11 -1
- package/dist/prover/prover.d.ts +4 -15
- package/dist/prover/prover.d.ts.map +1 -1
- package/dist/prover/prover.js +86 -103
- package/dist/prover/registry.d.ts +1 -1
- package/dist/prover/registry.js +3 -3
- package/dist/state/merkle/index.d.ts +1 -1
- package/dist/state/merkle/index.d.ts.map +1 -1
- package/dist/state/merkle/index.js +1 -1
- package/dist/state/merkle/merkle-tree.d.ts +0 -8
- package/dist/state/merkle/merkle-tree.d.ts.map +1 -1
- package/dist/state/merkle/merkle-tree.js +1 -9
- package/dist/state/store/index.d.ts +2 -3
- package/dist/state/store/index.d.ts.map +1 -1
- package/dist/state/store/index.js +0 -1
- package/dist/state/store/job-store.d.ts +7 -7
- package/dist/state/store/job-store.d.ts.map +1 -1
- package/dist/state/store/job-store.js +11 -15
- package/dist/state/store/jobs.d.ts +11 -34
- package/dist/state/store/jobs.d.ts.map +1 -1
- package/dist/state/store/leaf-store.d.ts.map +1 -1
- package/dist/state/store/leaf-store.js +3 -0
- package/dist/state/store/note-store.d.ts +7 -3
- package/dist/state/store/note-store.d.ts.map +1 -1
- package/dist/state/store/note-store.js +33 -19
- package/dist/state/store/nullifier-store.d.ts.map +1 -1
- package/dist/state/store/nullifier-store.js +2 -0
- package/dist/state/store/records.d.ts +2 -25
- package/dist/state/store/records.d.ts.map +1 -1
- package/dist/state/store/root-store.d.ts.map +1 -1
- package/dist/state/store/root-store.js +4 -0
- package/dist/state/store/store.d.ts +27 -45
- package/dist/state/store/store.d.ts.map +1 -1
- package/dist/state/store/store.js +0 -3
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js +1 -5
- package/dist/transactions/deposit.d.ts +16 -9
- package/dist/transactions/deposit.d.ts.map +1 -1
- package/dist/transactions/deposit.js +154 -110
- package/dist/transactions/index.d.ts +4 -6
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/transactions/index.js +2 -6
- package/dist/transactions/note-sync.d.ts +30 -7
- package/dist/transactions/note-sync.d.ts.map +1 -1
- package/dist/transactions/note-sync.js +6 -22
- package/dist/transactions/reconcile.d.ts +12 -10
- package/dist/transactions/reconcile.d.ts.map +1 -1
- package/dist/transactions/reconcile.js +6 -51
- package/dist/transactions/transact.d.ts +28 -9
- package/dist/transactions/transact.d.ts.map +1 -1
- package/dist/transactions/transact.js +506 -343
- package/dist/transactions/types.d.ts +114 -0
- package/dist/transactions/types.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/crypto.d.ts +5 -5
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +1 -1
- package/dist/utils/signature.d.ts +0 -6
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +6 -8
- package/dist/utils/validators.d.ts +10 -21
- package/dist/utils/validators.d.ts.map +1 -1
- package/dist/utils/validators.js +1 -27
- package/package.json +3 -5
- package/dist/account/account.d.ts.map +0 -1
- package/dist/crypto-adapters/auto-init.d.ts +0 -2
- package/dist/crypto-adapters/auto-init.d.ts.map +0 -1
- package/dist/crypto-adapters/auto-init.js +0 -7
- package/dist/crypto-adapters/index.d.ts +0 -22
- package/dist/crypto-adapters/index.d.ts.map +0 -1
- package/dist/crypto-adapters/index.js +0 -46
- package/dist/crypto-adapters/polyfills.d.ts +0 -5
- package/dist/crypto-adapters/polyfills.d.ts.map +0 -1
- package/dist/crypto-adapters/polyfills.js +0 -8
- package/dist/history/index.d.ts +0 -3
- package/dist/history/index.d.ts.map +0 -1
- package/dist/history/index.js +0 -2
- package/dist/history/service.d.ts +0 -46
- package/dist/history/service.d.ts.map +0 -1
- package/dist/history/service.js +0 -354
- package/dist/history/types.d.ts +0 -21
- package/dist/history/types.d.ts.map +0 -1
- package/dist/state/store/history-store.d.ts +0 -24
- package/dist/state/store/history-store.d.ts.map +0 -1
- package/dist/state/store/history-store.js +0 -53
- package/dist/transactions/note-selection.d.ts +0 -17
- package/dist/transactions/note-selection.d.ts.map +0 -1
- package/dist/transactions/note-selection.js +0 -196
- package/dist/transactions/transaction-planner.d.ts +0 -34
- package/dist/transactions/transaction-planner.d.ts.map +0 -1
- package/dist/transactions/transaction-planner.js +0 -115
- package/dist/transactions/types/deposit.d.ts +0 -48
- package/dist/transactions/types/deposit.d.ts.map +0 -1
- package/dist/transactions/types/deposit.js +0 -1
- package/dist/transactions/types/domain.d.ts +0 -67
- package/dist/transactions/types/domain.d.ts.map +0 -1
- package/dist/transactions/types/domain.js +0 -4
- package/dist/transactions/types/index.d.ts +0 -18
- package/dist/transactions/types/index.d.ts.map +0 -1
- package/dist/transactions/types/index.js +0 -17
- package/dist/transactions/types/options.d.ts +0 -41
- package/dist/transactions/types/options.d.ts.map +0 -1
- package/dist/transactions/types/options.js +0 -1
- package/dist/transactions/types/planning.d.ts +0 -80
- package/dist/transactions/types/planning.d.ts.map +0 -1
- package/dist/transactions/types/planning.js +0 -1
- package/dist/transactions/types/state-stores.d.ts +0 -51
- package/dist/transactions/types/state-stores.d.ts.map +0 -1
- package/dist/transactions/types/state-stores.js +0 -1
- package/dist/transactions/types/transact.d.ts +0 -61
- package/dist/transactions/types/transact.d.ts.map +0 -1
- package/dist/transactions/types/transact.js +0 -1
- package/dist/transactions/withdrawal-planner.d.ts +0 -61
- package/dist/transactions/withdrawal-planner.d.ts.map +0 -1
- package/dist/transactions/withdrawal-planner.js +0 -99
- package/dist/utils/amounts.d.ts +0 -39
- package/dist/utils/amounts.d.ts.map +0 -1
- package/dist/utils/amounts.js +0 -89
- package/dist/utils/format.d.ts +0 -25
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -33
- package/dist/utils/notes.d.ts +0 -15
- package/dist/utils/notes.d.ts.map +0 -1
- package/dist/utils/notes.js +0 -14
- package/dist/utils/random.d.ts +0 -13
- package/dist/utils/random.d.ts.map +0 -1
- package/dist/utils/random.js +0 -27
- package/dist/utils/secure-memory.d.ts +0 -25
- package/dist/utils/secure-memory.d.ts.map +0 -1
- package/dist/utils/secure-memory.js +0 -28
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -18
- /package/dist/{history → transactions}/types.js +0 -0
|
@@ -14,16 +14,14 @@ export type GenerateMasterSeedOptions = {
|
|
|
14
14
|
export declare const MASTER_SEED_LENGTH = 64;
|
|
15
15
|
export declare const MASTER_SEED_KEY = "cfg:wallet:master_seed/v1";
|
|
16
16
|
export declare const MASTER_MNEMONIC_KEY = "cfg:wallet:master_mnemonic/v1";
|
|
17
|
-
export type
|
|
17
|
+
export type ZkAccount = {
|
|
18
18
|
spendingKeyPair: SpendingKeyPair;
|
|
19
19
|
viewingKeyPair: ViewingKeyPair;
|
|
20
20
|
nullifyingKey: bigint;
|
|
21
21
|
masterPublicKey: bigint;
|
|
22
|
-
/** Bech32m address (0zk1...) for this account */
|
|
23
|
-
address: string;
|
|
24
22
|
};
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
23
|
+
export declare function deriveZkAccount(masterSeed: Uint8Array, accountIndex?: number): Promise<ZkAccount>;
|
|
24
|
+
export declare function deriveZkAccountFromMnemonic(mnemonic: string, accountIndex?: number, password?: string): Promise<ZkAccount>;
|
|
27
25
|
export declare function generateMasterSeed({ storage, rng, crypto, overwrite, mnemonicPassphrase, }: GenerateMasterSeedOptions): Promise<Uint8Array>;
|
|
28
26
|
export declare function loadMasterSeed(storage: Storage, crypto?: MasterSeedCrypto): Promise<Uint8Array | null>;
|
|
29
27
|
export declare function storeMasterSeed(storage: Storage, seed: Uint8Array, crypto?: MasterSeedCrypto): Promise<void>;
|
|
@@ -37,4 +35,4 @@ export type ImportMasterMnemonicOptions = {
|
|
|
37
35
|
};
|
|
38
36
|
export declare function importMasterMnemonic({ storage, mnemonic, crypto, overwrite, password, }: ImportMasterMnemonicOptions): Promise<Uint8Array>;
|
|
39
37
|
export declare function storeMasterMnemonic(storage: Storage, mnemonic: string, crypto?: MasterSeedCrypto): Promise<void>;
|
|
40
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=zkAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zkAccount.d.ts","sourceRoot":"","sources":["../../account/zkAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IAC5D,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;IAC/B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,eAAe,8BAA8B,CAAC;AAC3D,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AAOnE,MAAM,MAAM,SAAS,GAAG;IACtB,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAsB,eAAe,CACnC,UAAU,EAAE,UAAU,EACtB,YAAY,GAAE,MAAU,GACvB,OAAO,CAAC,SAAS,CAAC,CAqBpB;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,MAAU,EACxB,QAAQ,GAAE,MAAW,GACpB,OAAO,CAAC,SAAS,CAAC,CAIpB;AAWD,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,GAAG,EACH,MAAiC,EACjC,SAAiB,EACjB,kBAAkB,GACnB,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC,CA0BjD;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,gBAA2C,GAClD,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAK5B;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,gBAA2C,GAClD,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,gBAA2C,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMxB;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,EACzC,OAAO,EACP,QAAQ,EACR,MAAiC,EACjC,SAAiB,EACjB,QAAa,GACd,EAAE,2BAA2B,GAAG,OAAO,CAAC,UAAU,CAAC,CAenD;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,gBAA2C,GAClD,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { encodeAddress } from "../key-derivation/bech32.js";
|
|
2
1
|
import { Mnemonic } from "../key-derivation/bip39.js";
|
|
3
2
|
import { ByteUtils } from "../key-derivation/bytes.js";
|
|
4
3
|
import { deriveNodesFromSeed, WalletNode, } from "../key-derivation/wallet-node.js";
|
|
5
|
-
import { zeroize } from "../utils/secure-memory.js";
|
|
6
4
|
export const MASTER_SEED_LENGTH = 64;
|
|
7
5
|
export const MASTER_SEED_KEY = "cfg:wallet:master_seed/v1";
|
|
8
6
|
export const MASTER_MNEMONIC_KEY = "cfg:wallet:master_mnemonic/v1";
|
|
9
7
|
const MNEMONIC_ENTROPY_BYTES = 32;
|
|
10
8
|
const textEncoder = new TextEncoder();
|
|
11
9
|
const textDecoder = new TextDecoder();
|
|
12
|
-
export async function
|
|
10
|
+
export async function deriveZkAccount(masterSeed, accountIndex = 0) {
|
|
13
11
|
const seed = normalizeMasterSeed(masterSeed);
|
|
14
12
|
if (!Number.isInteger(accountIndex) || accountIndex < 0) {
|
|
15
13
|
throw new Error("accountIndex must be a non-negative integer");
|
|
@@ -19,27 +17,17 @@ export async function deriveAccount(masterSeed, accountIndex = 0) {
|
|
|
19
17
|
const viewingKeyPair = await viewing.getViewingKeyPair();
|
|
20
18
|
const nullifyingKey = WalletNode.getNullifyingKey(viewingKeyPair.privateKey);
|
|
21
19
|
const masterPublicKey = WalletNode.getMasterPublicKey(spendingKeyPair.pubkey, nullifyingKey);
|
|
22
|
-
const address = encodeAddress({
|
|
23
|
-
masterPublicKey,
|
|
24
|
-
viewingPublicKey: viewingKeyPair.pubkey,
|
|
25
|
-
});
|
|
26
20
|
return {
|
|
27
21
|
spendingKeyPair,
|
|
28
22
|
viewingKeyPair,
|
|
29
23
|
nullifyingKey,
|
|
30
24
|
masterPublicKey,
|
|
31
|
-
address,
|
|
32
25
|
};
|
|
33
26
|
}
|
|
34
|
-
export async function
|
|
27
|
+
export async function deriveZkAccountFromMnemonic(mnemonic, accountIndex = 0, password = "") {
|
|
35
28
|
const normalized = normalizeMnemonic(mnemonic);
|
|
36
29
|
const seed = mnemonicToSeed(normalized, password);
|
|
37
|
-
|
|
38
|
-
return await deriveAccount(seed, accountIndex);
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
zeroize(seed);
|
|
42
|
-
}
|
|
30
|
+
return deriveZkAccount(seed, accountIndex);
|
|
43
31
|
}
|
|
44
32
|
const identityMasterSeedCrypto = {
|
|
45
33
|
encrypt(seed) {
|
|
@@ -65,16 +53,11 @@ export async function generateMasterSeed({ storage, rng, crypto = identityMaster
|
|
|
65
53
|
if (entropy.length !== MNEMONIC_ENTROPY_BYTES) {
|
|
66
54
|
throw new Error(`mnemonic entropy must be ${MNEMONIC_ENTROPY_BYTES} bytes`);
|
|
67
55
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return seed;
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
zeroize(entropy);
|
|
77
|
-
}
|
|
56
|
+
const mnemonic = Mnemonic.fromEntropy(ByteUtils.bytesToHex(entropy));
|
|
57
|
+
await storeMasterMnemonic(storage, mnemonic, crypto);
|
|
58
|
+
const seed = mnemonicToSeed(mnemonic, mnemonicPassphrase);
|
|
59
|
+
await storeMasterSeed(storage, seed, crypto);
|
|
60
|
+
return seed;
|
|
78
61
|
}
|
|
79
62
|
export async function loadMasterSeed(storage, crypto = identityMasterSeedCrypto) {
|
|
80
63
|
const stored = await storage.get(MASTER_SEED_KEY);
|
|
@@ -96,13 +79,8 @@ export async function loadMasterMnemonic(storage, crypto = identityMasterSeedCry
|
|
|
96
79
|
if (!stored)
|
|
97
80
|
return null;
|
|
98
81
|
const plaintext = await crypto.decrypt(stored);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return normalizeMnemonic(mnemonic);
|
|
102
|
-
}
|
|
103
|
-
finally {
|
|
104
|
-
zeroize(plaintext);
|
|
105
|
-
}
|
|
82
|
+
const mnemonic = textDecoder.decode(plaintext);
|
|
83
|
+
return normalizeMnemonic(mnemonic);
|
|
106
84
|
}
|
|
107
85
|
export async function importMasterMnemonic({ storage, mnemonic, crypto = identityMasterSeedCrypto, overwrite = false, password = "", }) {
|
|
108
86
|
if (!overwrite) {
|
package/dist/clients/http.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
2
|
-
/**
|
|
3
|
-
* Resolve fetch implementation from options or global.
|
|
4
|
-
* @param providedFetch - Optional fetch implementation
|
|
5
|
-
* @returns Fetch function or undefined if not available
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolveFetch(providedFetch?: FetchLike): typeof fetch | undefined;
|
|
8
2
|
export type JsonHttpDeps = {
|
|
9
3
|
fetch: FetchLike;
|
|
10
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../clients/http.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../clients/http.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC;AAEF,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK3D;AAWD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,YAAY,GACjB,cAAc,CA+ChB"}
|
package/dist/clients/http.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import ky, { HTTPError, TimeoutError } from "ky";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve fetch implementation from options or global.
|
|
4
|
-
* @param providedFetch - Optional fetch implementation
|
|
5
|
-
* @returns Fetch function or undefined if not available
|
|
6
|
-
*/
|
|
7
|
-
export function resolveFetch(providedFetch) {
|
|
8
|
-
return providedFetch ?? (typeof fetch === "function" ? fetch : undefined);
|
|
9
|
-
}
|
|
10
2
|
export class HttpError extends Error {
|
|
11
3
|
status;
|
|
12
4
|
body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../clients/indexer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../clients/indexer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAc3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AASF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAQF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB;iCAyB9D,sBAAsB,GAC7B,OAAO,CAAC,uBAAuB,CAAC;0BAgBzB,mBAAmB,GAC1B,OAAO,CAAC,gBAAgB,CAAC;yBAQlB,kBAAkB,GACzB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;+BAcR,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;EAQ5D"}
|
package/dist/clients/indexer.js
CHANGED
|
@@ -11,7 +11,6 @@ export function createIndexerClient(baseUrl, deps) {
|
|
|
11
11
|
root: record.root,
|
|
12
12
|
txHash: record.tx_hash,
|
|
13
13
|
insertedAt: record.inserted_at,
|
|
14
|
-
eventType: record.event_type ?? "unknown",
|
|
15
14
|
});
|
|
16
15
|
const normalizeNullifierRecord = (record) => ({
|
|
17
16
|
nullifier: record.nullifier,
|
package/dist/config.d.ts
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for a specific environment.
|
|
7
|
-
*/
|
|
8
|
-
export interface EnvironmentConfig {
|
|
9
|
-
rpcUrl: string;
|
|
10
|
-
poolAddress: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Service configuration with broadcaster and indexer URLs.
|
|
14
|
-
*/
|
|
15
|
-
export interface ServiceConfig {
|
|
1
|
+
export declare const serviceConfig: {
|
|
2
|
+
/**
|
|
3
|
+
* Base URL for the Broadcaster HTTP API (default: http://localhost:8081).
|
|
4
|
+
*/
|
|
16
5
|
broadcasterBaseUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Base URL for the Indexer HTTP API (default: http://localhost:8082).
|
|
8
|
+
*/
|
|
17
9
|
indexerBaseUrl: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
* Fetch environment configuration from the hosted config file.
|
|
21
|
-
*
|
|
22
|
-
* @param env - The environment to fetch config for
|
|
23
|
-
* @returns Promise resolving to the environment configuration
|
|
24
|
-
* @throws If fetch fails or environment is not found
|
|
25
|
-
*/
|
|
26
|
-
export declare function fetchEnvironmentConfig(env: Environment): Promise<EnvironmentConfig>;
|
|
27
|
-
/**
|
|
28
|
-
* Create service configuration from an RPC URL.
|
|
29
|
-
*
|
|
30
|
-
* @param rpcUrl - The base RPC URL
|
|
31
|
-
* @returns Service configuration with broadcaster and indexer URLs
|
|
32
|
-
*/
|
|
33
|
-
export declare function createServiceConfig(rpcUrl: string): ServiceConfig;
|
|
10
|
+
};
|
|
11
|
+
export type ServiceConfig = typeof serviceConfig;
|
|
34
12
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,aAAa;IACxB;;OAEG;;IAGH;;OAEG;;CAGJ,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @param env - The environment to fetch config for
|
|
6
|
-
* @returns Promise resolving to the environment configuration
|
|
7
|
-
* @throws If fetch fails or environment is not found
|
|
8
|
-
*/
|
|
9
|
-
export async function fetchEnvironmentConfig(env) {
|
|
10
|
-
const res = await fetch(CONFIG_URL);
|
|
11
|
-
if (!res.ok) {
|
|
12
|
-
throw new Error(`Failed to fetch SDK config: ${res.status}`);
|
|
1
|
+
const DEFAULT_RPC_URL = "http://localhost:3000";
|
|
2
|
+
function readEnv(key) {
|
|
3
|
+
if (typeof process !== "undefined" && process?.env) {
|
|
4
|
+
return process.env[key];
|
|
13
5
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return config[env];
|
|
6
|
+
// Support environments where process isn't defined but a shim sets globalThis.process
|
|
7
|
+
const globalProcess = globalThis.process;
|
|
8
|
+
return globalProcess?.env?.[key];
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
broadcasterBaseUrl: baseUrl + "/broadcaster",
|
|
30
|
-
indexerBaseUrl: baseUrl + "/indexer",
|
|
31
|
-
};
|
|
10
|
+
function readServiceUrl(envKey, fallback) {
|
|
11
|
+
const raw = readEnv(envKey);
|
|
12
|
+
if (!raw)
|
|
13
|
+
return fallback;
|
|
14
|
+
const trimmed = raw.trim();
|
|
15
|
+
if (!trimmed) {
|
|
16
|
+
throw new Error(`${envKey} must not be empty when set`);
|
|
17
|
+
}
|
|
18
|
+
return trimmed.replace(/\/+$/, "");
|
|
32
19
|
}
|
|
20
|
+
export const serviceConfig = {
|
|
21
|
+
/**
|
|
22
|
+
* Base URL for the Broadcaster HTTP API (default: http://localhost:8081).
|
|
23
|
+
*/
|
|
24
|
+
broadcasterBaseUrl: readServiceUrl("UNLINK_RPC_URL", DEFAULT_RPC_URL) + "/broadcaster",
|
|
25
|
+
/**
|
|
26
|
+
* Base URL for the Indexer HTTP API (default: http://localhost:8082).
|
|
27
|
+
*/
|
|
28
|
+
indexerBaseUrl: readServiceUrl("UNLINK_RPC_URL", DEFAULT_RPC_URL) + "/indexer",
|
|
29
|
+
};
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;CAChC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,IAAI,EAAE,QAAQ;;aAHlC,MAAM,KAAK,UAAU;GAW/B"}
|
package/dist/core.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { initCrypto } from "./crypto-adapters/index.js";
|
|
2
1
|
import { migrate } from "./schema.js";
|
|
3
2
|
export async function initCore(deps) {
|
|
4
3
|
if (!deps?.storage)
|
|
5
4
|
throw new Error("storage dep required");
|
|
6
5
|
if (!deps?.rng)
|
|
7
6
|
throw new Error("rng dep required");
|
|
8
|
-
await initCrypto();
|
|
9
7
|
await migrate(deps.storage);
|
|
10
8
|
return {
|
|
11
9
|
storage: deps.storage,
|
package/dist/index.d.ts
CHANGED
|
@@ -8,18 +8,13 @@ export * from "./core.js";
|
|
|
8
8
|
export * from "./state/index.js";
|
|
9
9
|
export * from "./utils/validators.js";
|
|
10
10
|
export * from "./utils/bigint.js";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./utils/amounts.js";
|
|
13
|
-
export * from "./utils/notes.js";
|
|
14
|
-
export * from "./utils/format.js";
|
|
15
|
-
export * from "./account/account.js";
|
|
11
|
+
export * from "./account/zkAccount.js";
|
|
16
12
|
export * from "./key-derivation/index.js";
|
|
17
|
-
export * from "./history/index.js";
|
|
18
13
|
export * from "./transactions/index.js";
|
|
19
|
-
export {
|
|
20
|
-
export
|
|
14
|
+
export { createJobReconciler } from "./transactions/reconcile.js";
|
|
15
|
+
export { serviceConfig } from "./config.js";
|
|
16
|
+
export type { ServiceConfig } from "./config.js";
|
|
21
17
|
export * from "./clients/broadcaster.js";
|
|
22
18
|
export * from "./clients/indexer.js";
|
|
23
|
-
export * from "./crypto-adapters/index.js";
|
|
24
19
|
export { circuitsConfig };
|
|
25
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,iBAAiB,CAAuB;AAEnE,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,iBAAiB,CAAuB;AAEnE,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,16 +9,11 @@ export * from "./core.js";
|
|
|
9
9
|
export * from "./state/index.js";
|
|
10
10
|
export * from "./utils/validators.js";
|
|
11
11
|
export * from "./utils/bigint.js";
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./utils/amounts.js";
|
|
14
|
-
export * from "./utils/notes.js";
|
|
15
|
-
export * from "./utils/format.js";
|
|
16
|
-
export * from "./account/account.js";
|
|
12
|
+
export * from "./account/zkAccount.js";
|
|
17
13
|
export * from "./key-derivation/index.js";
|
|
18
|
-
export * from "./history/index.js";
|
|
19
14
|
export * from "./transactions/index.js";
|
|
20
|
-
export {
|
|
15
|
+
export { createJobReconciler } from "./transactions/reconcile.js";
|
|
16
|
+
export { serviceConfig } from "./config.js";
|
|
21
17
|
export * from "./clients/broadcaster.js";
|
|
22
18
|
export * from "./clients/indexer.js";
|
|
23
|
-
export * from "./crypto-adapters/index.js";
|
|
24
19
|
export { circuitsConfig };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight wrapper exposing the BabyJubJub point packing helpers we rely on for
|
|
3
|
+
* derivation and address encoding. Re-exported for consumers that need raw curve ops.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Babyjubjub {
|
|
6
|
+
static packPoint: (point: [bigint, bigint]) => Uint8Array;
|
|
7
|
+
static unpackPoint: (bytes: Uint8Array) => [bigint, bigint];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=babyjubjub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babyjubjub.d.ts","sourceRoot":"","sources":["../../key-derivation/babyjubjub.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,UAAU;IACrB,MAAM,CAAC,SAAS,0CAAqB;IAErC,MAAM,CAAC,WAAW,0CAAuB;CAC1C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { babyjub } from "@railgun-community/circomlibjs";
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight wrapper exposing the BabyJubJub point packing helpers we rely on for
|
|
4
|
+
* derivation and address encoding. Re-exported for consumers that need raw curve ops.
|
|
5
|
+
*/
|
|
6
|
+
export class Babyjubjub {
|
|
7
|
+
static packPoint = babyjub.packPoint;
|
|
8
|
+
static unpackPoint = babyjub.unpackPoint;
|
|
9
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bip39.d.ts","sourceRoot":"","sources":["../../key-derivation/bip39.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bip39.d.ts","sourceRoot":"","sources":["../../key-derivation/bip39.ts"],"names":[],"mappings":"AAqBA,qBAAa,QAAQ;IACnB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAE,GAAG,GAAG,GAAG,GAAG,GAAS,GAAG,MAAM;IAIxD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI1C;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM;IAK9D,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAK1C,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAK9C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;IAWzE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;CAOvE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Buffer } from "buffer";
|
|
2
1
|
import { entropyToMnemonic, generateMnemonic, mnemonicToEntropy, mnemonicToSeedSync, validateMnemonic, } from "@scure/bip39";
|
|
3
2
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
4
3
|
import { HDKey } from "ethereum-cryptography/hdkey";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../key-derivation/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../key-derivation/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
@@ -28,15 +28,13 @@ export declare class WalletNode {
|
|
|
28
28
|
*/
|
|
29
29
|
derive(path: string): WalletNode;
|
|
30
30
|
/**
|
|
31
|
-
* Derive the BabyJubJub spending key pair (private scalar + affine point)
|
|
31
|
+
* Derive the BabyJubJub spending key pair (private scalar + affine point).
|
|
32
32
|
*/
|
|
33
33
|
getSpendingKeyPair(): SpendingKeyPair;
|
|
34
34
|
static getMasterPublicKey(spendingPublicKey: SpendingPublicKey, nullifyingKey: bigint): bigint;
|
|
35
35
|
static getNullifyingKey(viewingPrivateKey: Uint8Array): bigint;
|
|
36
36
|
/**
|
|
37
37
|
* Derive the Ed25519 viewing key pair for encrypted note retrieval.
|
|
38
|
-
*
|
|
39
|
-
* The returned privateKey should be zeroized after use.
|
|
40
38
|
*/
|
|
41
39
|
getViewingKeyPair(): Promise<ViewingKeyPair>;
|
|
42
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-node.d.ts","sourceRoot":"","sources":["../../key-derivation/wallet-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet-node.d.ts","sourceRoot":"","sources":["../../key-derivation/wallet-node.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,OAAO,EACR,MAAM,YAAY,CAAC;AASpB,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAgB5E,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAExE,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,QAAO,MAAU,KAChB,WAOF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,UAAU,EAChB,QAAO,MAAU,KAChB,WAOF,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,IAAI,EAAE,OAAO;IAKzB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;IAKjD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU;IAQtD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAUhC;;OAEG;IACH,kBAAkB,IAAI,eAAe;IASrC,MAAM,CAAC,kBAAkB,CACvB,iBAAiB,EAAE,iBAAiB,EACpC,aAAa,EAAE,MAAM,GACpB,MAAM;IAIT,MAAM,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,GAAG,MAAM;IAW9D;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IASlD;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAI1C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
1
2
|
import { getPublicKey, hashes } from "@noble/ed25519";
|
|
2
3
|
import { sha512 } from "@noble/hashes/sha2";
|
|
3
|
-
import {
|
|
4
|
+
import { eddsa, poseidon } from "@railgun-community/circomlibjs";
|
|
4
5
|
import { childKeyDerivationHardened, getMasterKeyFromSeed, getPathSegments, } from "./bip32.js";
|
|
5
6
|
import { Mnemonic } from "./bip39.js";
|
|
6
7
|
import { ByteUtils } from "./bytes.js";
|
|
@@ -64,14 +65,14 @@ export class WalletNode {
|
|
|
64
65
|
return new WalletNode(derived);
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
|
-
* Derive the BabyJubJub spending key pair (private scalar + affine point)
|
|
68
|
+
* Derive the BabyJubJub spending key pair (private scalar + affine point).
|
|
68
69
|
*/
|
|
69
70
|
getSpendingKeyPair() {
|
|
70
71
|
const privateKey = ByteUtils.hexStringToBytes(this.chainKey);
|
|
71
72
|
if (privateKey.length !== 32) {
|
|
72
73
|
throw new Error("Spending private key must be 32 bytes");
|
|
73
74
|
}
|
|
74
|
-
const pubkey =
|
|
75
|
+
const pubkey = eddsa.prv2pub(Buffer.from(privateKey));
|
|
75
76
|
return { privateKey, pubkey };
|
|
76
77
|
}
|
|
77
78
|
static getMasterPublicKey(spendingPublicKey, nullifyingKey) {
|
|
@@ -89,8 +90,6 @@ export class WalletNode {
|
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
92
|
* Derive the Ed25519 viewing key pair for encrypted note retrieval.
|
|
92
|
-
*
|
|
93
|
-
* The returned privateKey should be zeroized after use.
|
|
94
93
|
*/
|
|
95
94
|
async getViewingKeyPair() {
|
|
96
95
|
const privateKey = ByteUtils.hexStringToBytes(this.chainKey);
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
export declare const RESERVED_PREFIXES: readonly ["meta:", "
|
|
1
|
+
export declare const RESERVED_PREFIXES: readonly ["meta:", "notes:", "leaves:", "roots:", "nullifiers:", "ciphertexts:", "jobs:", "proof_cache:", "cfg:", "idx:", "locks:"];
|
|
2
2
|
/** Canonical builders for storage key namespaces used across core */
|
|
3
3
|
export declare const keys: {
|
|
4
4
|
note: (c: number, i: number) => string;
|
|
5
|
-
historyEntry: (id: string) => string;
|
|
6
|
-
historyPrefix: (chainId: number, mpk: string) => string;
|
|
7
|
-
historyMeta: (chainId: number, mpk: string) => string;
|
|
8
5
|
leaf: (c: number, i: number) => string;
|
|
9
6
|
ciphertext: (c: number, i: number) => string;
|
|
10
7
|
/** Track note indices that remain unspent for a given master public key (mpk acts as the account identifier). */
|
package/dist/keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../keys.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../keys.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,qIAYpB,CAAC;AAEX,qEAAqE;AACrE,eAAO,MAAM,IAAI;cACL,MAAM,KAAK,MAAM;cACjB,MAAM,KAAK,MAAM;oBACX,MAAM,KAAK,MAAM;IACjC,iHAAiH;iBACpG,MAAM,OAAO,MAAM,KAAK,MAAM;uBAExB,MAAM,OAAO,MAAM;sBACpB,MAAM,KAAK,MAAM;qBAClB,MAAM,KAAK,MAAM;mBACnB,MAAM,KAAK,MAAM;cACtB,MAAM,SAAS,MAAM;oBACf,MAAM;oBACN,MAAM;gBACV,MAAM;mBACH,MAAM,KAAK,MAAM;mBACjB,MAAM;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,QAQtC"}
|
package/dist/keys.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { KeyValidationError } from "./errors.js";
|
|
2
2
|
export const RESERVED_PREFIXES = [
|
|
3
3
|
"meta:",
|
|
4
|
-
"history:",
|
|
5
4
|
"notes:",
|
|
6
5
|
"leaves:",
|
|
7
6
|
"roots:",
|
|
@@ -16,9 +15,6 @@ export const RESERVED_PREFIXES = [
|
|
|
16
15
|
/** Canonical builders for storage key namespaces used across core */
|
|
17
16
|
export const keys = {
|
|
18
17
|
note: (c, i) => `notes:${c}:${i}`,
|
|
19
|
-
historyEntry: (id) => `history:${id}`,
|
|
20
|
-
historyPrefix: (chainId, mpk) => `history:${chainId}:${mpk}:`,
|
|
21
|
-
historyMeta: (chainId, mpk) => `history:${chainId}:${mpk}:__meta__`,
|
|
22
18
|
leaf: (c, i) => `leaves:${c}:${i}`,
|
|
23
19
|
ciphertext: (c, i) => `ciphertexts:${c}:${i}`,
|
|
24
20
|
/** Track note indices that remain unspent for a given master public key (mpk acts as the account identifier). */
|
package/dist/prover/config.d.ts
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
* Configuration for the prover system
|
|
3
3
|
* Handles artifact loading from local files or remote artifact server
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Environment-based configuration for artifact loading
|
|
7
|
+
*/
|
|
8
|
+
export interface ProverConfig {
|
|
9
|
+
/** Base URL for the artifact server (browser mode) */
|
|
10
|
+
rpcUrl: string;
|
|
11
|
+
/** Whether to enable artifact caching */
|
|
12
|
+
enableCache: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Default configuration
|
|
16
|
+
* Can be overridden via environment variables
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_CONFIG: ProverConfig;
|
|
5
19
|
/**
|
|
6
20
|
* Artifact file types
|
|
7
21
|
*/
|
|
@@ -17,7 +31,7 @@ export declare enum ArtifactType {
|
|
|
17
31
|
* @param baseUrl Base URL of the artifact server
|
|
18
32
|
* @returns Full URL to the artifact
|
|
19
33
|
*/
|
|
20
|
-
export declare function buildArtifactUrl(circuitName: string, artifactType: ArtifactType, baseUrl
|
|
34
|
+
export declare function buildArtifactUrl(circuitName: string, artifactType: ArtifactType, baseUrl?: string): string;
|
|
21
35
|
/**
|
|
22
36
|
* Get relative path for local artifact loading
|
|
23
37
|
* Used in Node.js environment when artifacts are bundled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../prover/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,YAAY;IACtB,IAAI,mBAAmB;IACvB,IAAI,mBAAmB;IACvB,IAAI,wBAAwB;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../prover/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAM5B,CAAC;AAEF;;GAEG;AACH,oBAAY,YAAY;IACtB,IAAI,mBAAmB;IACvB,IAAI,mBAAmB;IACvB,IAAI,wBAAwB;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,MAA8B,GACtC,MAAM,CAIR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,GACzB,MAAM,EAAE,CAQV;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;IAClB;;OAEG;iBACU,OAAO;IAIpB;;OAEG;cACO,OAAO;IAQjB;;OAEG;sBACe,MAAM;CAKzB,CAAC"}
|
package/dist/prover/config.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
* Configuration for the prover system
|
|
3
3
|
* Handles artifact loading from local files or remote artifact server
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default configuration
|
|
7
|
+
* Can be overridden via environment variables
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_CONFIG = {
|
|
10
|
+
rpcUrl: typeof process !== "undefined" && process.env?.UNLINK_RPC_URL
|
|
11
|
+
? process.env.UNLINK_RPC_URL
|
|
12
|
+
: "http://localhost:3000",
|
|
13
|
+
enableCache: true,
|
|
14
|
+
};
|
|
5
15
|
/**
|
|
6
16
|
* Artifact file types
|
|
7
17
|
*/
|
|
@@ -18,7 +28,7 @@ export var ArtifactType;
|
|
|
18
28
|
* @param baseUrl Base URL of the artifact server
|
|
19
29
|
* @returns Full URL to the artifact
|
|
20
30
|
*/
|
|
21
|
-
export function buildArtifactUrl(circuitName, artifactType, baseUrl) {
|
|
31
|
+
export function buildArtifactUrl(circuitName, artifactType, baseUrl = DEFAULT_CONFIG.rpcUrl) {
|
|
22
32
|
// Remove trailing slash from baseUrl
|
|
23
33
|
const cleanBaseUrl = baseUrl.replace(/\/$/, "");
|
|
24
34
|
return `${cleanBaseUrl}/artifacts/${circuitName}/${artifactType}`;
|
package/dist/prover/prover.d.ts
CHANGED
|
@@ -30,30 +30,22 @@ export interface JoinsplitProofInput {
|
|
|
30
30
|
readonly npkOut: bigint[];
|
|
31
31
|
readonly valueOut: bigint[];
|
|
32
32
|
}
|
|
33
|
-
export declare function proveTransaction(input: JoinsplitProofInput
|
|
34
|
-
rpcUrl?: string;
|
|
35
|
-
}): Promise<JoinsplitProof>;
|
|
33
|
+
export declare function proveTransaction(input: JoinsplitProofInput): Promise<JoinsplitProof>;
|
|
36
34
|
/**
|
|
37
35
|
* Get verification key for a specific circuit configuration
|
|
38
36
|
* @param inputs Number of inputs (nullifiers)
|
|
39
37
|
* @param outputs Number of outputs (commitments)
|
|
40
|
-
* @param options Configuration including rpcUrl
|
|
41
38
|
* @returns Verification key for the circuit
|
|
42
39
|
*/
|
|
43
|
-
export declare function getVerificationKey(inputs: number, outputs: number
|
|
44
|
-
rpcUrl?: string;
|
|
45
|
-
}): Promise<VerificationKey>;
|
|
40
|
+
export declare function getVerificationKey(inputs: number, outputs: number): Promise<VerificationKey>;
|
|
46
41
|
/**
|
|
47
42
|
* Verify a proof with public signals
|
|
48
43
|
* Auto-detects the circuit from the public signals structure
|
|
49
44
|
* @param proof Groth16 proof
|
|
50
45
|
* @param publicSignals Public signals array
|
|
51
|
-
* @param options Optional configuration including rpcUrl
|
|
52
46
|
* @returns True if proof is valid
|
|
53
47
|
*/
|
|
54
|
-
export declare function verifyProof(proof: Groth16Proof, publicSignals: PublicSignals
|
|
55
|
-
rpcUrl?: string;
|
|
56
|
-
}): Promise<boolean>;
|
|
48
|
+
export declare function verifyProof(proof: Groth16Proof, publicSignals: PublicSignals): Promise<boolean>;
|
|
57
49
|
/**
|
|
58
50
|
* Verify a proof with explicit circuit specification
|
|
59
51
|
* Preferred method when you know the circuit dimensions
|
|
@@ -61,10 +53,7 @@ export declare function verifyProof(proof: Groth16Proof, publicSignals: PublicSi
|
|
|
61
53
|
* @param publicSignals Public signals array
|
|
62
54
|
* @param inputs Number of inputs (nullifiers)
|
|
63
55
|
* @param outputs Number of outputs (commitments)
|
|
64
|
-
* @param options Optional configuration including rpcUrl
|
|
65
56
|
* @returns True if proof is valid
|
|
66
57
|
*/
|
|
67
|
-
export declare function verifyProofWithCircuit(proof: Groth16Proof, publicSignals: PublicSignals, inputs: number, outputs: number
|
|
68
|
-
rpcUrl?: string;
|
|
69
|
-
}): Promise<boolean>;
|
|
58
|
+
export declare function verifyProofWithCircuit(proof: Groth16Proof, publicSignals: PublicSignals, inputs: number, outputs: number): Promise<boolean>;
|
|
70
59
|
//# sourceMappingURL=prover.d.ts.map
|