@audren-xyz/sdk 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +102 -2
- package/dist/constants.d.ts +229 -0
- package/dist/constants.js +301 -0
- package/dist/crypto.d.ts +85 -0
- package/dist/crypto.js +520 -0
- package/dist/idl.d.ts +4291 -0
- package/dist/idl.js +5608 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/instructions.d.ts +398 -0
- package/dist/instructions.js +1139 -0
- package/dist/keys.d.ts +67 -0
- package/dist/keys.js +194 -0
- package/dist/layout.d.ts +153 -0
- package/dist/layout.js +535 -0
- package/dist/pda.d.ts +65 -0
- package/dist/pda.js +508 -0
- package/dist/poseidon-constants.d.ts +13 -0
- package/dist/poseidon-constants.js +1401 -0
- package/dist/poseidon.d.ts +46 -0
- package/dist/poseidon.js +214 -0
- package/dist/prover-entry.d.ts +1 -0
- package/dist/prover-entry.js +1 -0
- package/dist/prover.d.ts +100 -0
- package/dist/prover.js +515 -0
- package/dist/relayer.d.ts +336 -0
- package/dist/relayer.js +258 -0
- package/dist/scanner.d.ts +262 -0
- package/dist/scanner.js +3119 -0
- package/dist/store.d.ts +186 -0
- package/dist/store.js +1403 -0
- package/dist/swap.d.ts +105 -0
- package/dist/swap.js +156 -0
- package/dist/token2022.d.ts +29 -0
- package/dist/token2022.js +168 -0
- package/dist/tx-v1.d.ts +63 -0
- package/dist/tx-v1.js +249 -0
- package/idl/audren.anchor.json +1750 -0
- package/idl/audren.codama.json +3856 -0
- package/package.json +76 -4
- package/wasm/audren_circuits.wasm +0 -0
- package/wasm/audren_joinsplit.pk +0 -0
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-indexer `CompactWalletStore` & 4-ary Depth-20 Merkle witness builder matching
|
|
3
|
+
* `crates/audren-circuits/src/merkle.rs` and `crates/client/src/store.rs` bit-for-bit.
|
|
4
|
+
*
|
|
5
|
+
* Discards every sealed `SubtreePage` (`8,256 B`), `MemoPage` (`10,240 B`), and stranger
|
|
6
|
+
* `NullifierPage` prefix immediately after scanning, persisting only frozen 12-sibling
|
|
7
|
+
* intra-subtree paths (`384 B` per owned note), `32 B` finalized level-4 subroots (`1.28 MB`
|
|
8
|
+
* at 10M pool notes), unsealed frontier tail leaves, and at most one just-sealed page per lane
|
|
9
|
+
* until `GlobalRootHistory.stable` crosses it.
|
|
10
|
+
*/
|
|
11
|
+
import { type DecryptedMemo } from './crypto.ts';
|
|
12
|
+
import type { FullViewingKey, SelectiveDisclosureProof } from './keys.ts';
|
|
13
|
+
import { type DecodedGlobalRootHistory, type RootSnapshotChoice } from './layout.ts';
|
|
14
|
+
export interface MerklePath4Ary {
|
|
15
|
+
siblings: bigint[][];
|
|
16
|
+
positions: number[];
|
|
17
|
+
}
|
|
18
|
+
export declare function emptyMerklePath4Ary(): MerklePath4Ary;
|
|
19
|
+
export declare function computeMerkleRoot4Ary(path: MerklePath4Ary, leaf: bigint): bigint;
|
|
20
|
+
export declare function extractIntraSubtreeSiblings(pageLeaves: readonly bigint[], validLen: number, targetOffset: number): {
|
|
21
|
+
siblings: bigint[][];
|
|
22
|
+
positions: number[];
|
|
23
|
+
};
|
|
24
|
+
export type WitnessLaneSnapshotParams = {
|
|
25
|
+
laneRoots: readonly bigint[];
|
|
26
|
+
laneLeafCount: bigint;
|
|
27
|
+
};
|
|
28
|
+
export declare function buildWitnessFromFrozenSubsiblings(params: {
|
|
29
|
+
laneId: number;
|
|
30
|
+
targetLeafIdx: bigint;
|
|
31
|
+
intraSiblings: readonly (readonly bigint[])[];
|
|
32
|
+
intraPositions: readonly number[];
|
|
33
|
+
finalizedSubtreeRoots: readonly bigint[];
|
|
34
|
+
frontierPageLeaves?: readonly bigint[];
|
|
35
|
+
} & WitnessLaneSnapshotParams): MerklePath4Ary;
|
|
36
|
+
export declare function buildHistoricalWitness4Ary(params: {
|
|
37
|
+
laneId: number;
|
|
38
|
+
targetLeafIdx: bigint;
|
|
39
|
+
finalizedSubtreeRoots: readonly bigint[];
|
|
40
|
+
targetPageLeaves: readonly bigint[];
|
|
41
|
+
frontierPageLeaves?: readonly bigint[];
|
|
42
|
+
} & WitnessLaneSnapshotParams): MerklePath4Ary;
|
|
43
|
+
export interface OwnedNote {
|
|
44
|
+
poolId: number;
|
|
45
|
+
laneId: number;
|
|
46
|
+
leafIndex: bigint;
|
|
47
|
+
globalLeafIndex: bigint;
|
|
48
|
+
mint: Uint8Array;
|
|
49
|
+
amount: bigint;
|
|
50
|
+
tweak: Uint8Array;
|
|
51
|
+
blinding: Uint8Array;
|
|
52
|
+
stealthOwner: Uint8Array;
|
|
53
|
+
commitment: Uint8Array;
|
|
54
|
+
nullifier: Uint8Array;
|
|
55
|
+
paymentId: Uint8Array;
|
|
56
|
+
isDynamic: boolean;
|
|
57
|
+
spent: boolean;
|
|
58
|
+
frozenIntraSiblings: Uint8Array[][] | null;
|
|
59
|
+
frozenIntraPositions: number[] | null;
|
|
60
|
+
}
|
|
61
|
+
export interface CompactLaneState {
|
|
62
|
+
finalizedSubroots: Uint8Array[];
|
|
63
|
+
frontierSubSeq: bigint;
|
|
64
|
+
frontierLeaves: Uint8Array[];
|
|
65
|
+
prevSealedSubSeq: bigint | null;
|
|
66
|
+
prevSealedLeaves: Uint8Array[];
|
|
67
|
+
nextMemoLeaf: bigint;
|
|
68
|
+
nextNfIndex: bigint;
|
|
69
|
+
}
|
|
70
|
+
export declare function exportSelectiveDisclosureProof(note: OwnedNote): SelectiveDisclosureProof;
|
|
71
|
+
export declare class CompactWalletStore {
|
|
72
|
+
poolId: number;
|
|
73
|
+
birthdaySlot: bigint;
|
|
74
|
+
lanes: CompactLaneState[];
|
|
75
|
+
notes: OwnedNote[];
|
|
76
|
+
constructor(poolId?: number, birthdaySlot?: bigint);
|
|
77
|
+
/** Clear all cached lane state and notes and optionally set a new `birthdaySlot` for clean rescanning. */
|
|
78
|
+
reset(birthdaySlot?: bigint): void;
|
|
79
|
+
unspentNotes(mintHex?: string): OwnedNote[];
|
|
80
|
+
balancesByMintHex(): Map<string, bigint>;
|
|
81
|
+
/** Record a decrypted and commitment-verified owned note if not already tracked. */
|
|
82
|
+
recordVerifiedMemo(params: {
|
|
83
|
+
fvk: FullViewingKey;
|
|
84
|
+
laneId: number;
|
|
85
|
+
leafIdx: bigint;
|
|
86
|
+
decrypted: DecryptedMemo;
|
|
87
|
+
cmBe: Uint8Array;
|
|
88
|
+
}): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Freeze 12-sibling intra-subtree Merkle paths for every owned note in sealed
|
|
91
|
+
* `(laneId, subSeq)` so the `8,256 B` `SubtreePage` can be permanently discarded.
|
|
92
|
+
*/
|
|
93
|
+
freezeOwnedNotesInSubtreePage(laneId: number, subSeq: bigint, leaves: readonly Uint8Array[]): void;
|
|
94
|
+
/**
|
|
95
|
+
* Ingest one or more `SubtreeRootPage` accounts (`9,664 B`, 300 finalized subroots each)
|
|
96
|
+
* without downloading sealed `SubtreePage` accounts for subtrees containing no owned notes.
|
|
97
|
+
*
|
|
98
|
+
* Validates every page in sorted sequence order and enforces strict contiguity (zero
|
|
99
|
+
* zero-filled gaps, zero sparse amplification DoS, zero partial mutation on error) BEFORE
|
|
100
|
+
* writing any subroots into `finalizedSubroots`.
|
|
101
|
+
*/
|
|
102
|
+
ingestSubrootPages(params: {
|
|
103
|
+
laneId: number;
|
|
104
|
+
subrootPages: ReadonlyArray<{
|
|
105
|
+
rootPageSeq: bigint;
|
|
106
|
+
raw: Uint8Array;
|
|
107
|
+
}>;
|
|
108
|
+
finalizedCount?: bigint;
|
|
109
|
+
}): void;
|
|
110
|
+
/**
|
|
111
|
+
* Stream a single `NullifierPage` against our `O(owned_unspent_notes)` prefix index,
|
|
112
|
+
* marking matches `spent = true`, advancing `nextNfIndex`, and discarding stranger prefixes.
|
|
113
|
+
*/
|
|
114
|
+
ingestNullifierPage(params: {
|
|
115
|
+
laneId: number;
|
|
116
|
+
pageSeq: bigint;
|
|
117
|
+
raw: Uint8Array;
|
|
118
|
+
maxNfIndex?: bigint;
|
|
119
|
+
}): number;
|
|
120
|
+
private _validateNullifierPages;
|
|
121
|
+
private _applyValidatedNullifierPages;
|
|
122
|
+
/**
|
|
123
|
+
* Stream `NullifierPage`s in ascending sequence order against an `O(owned_unspent_notes)`
|
|
124
|
+
* lookup map (across all lanes), marking matching notes `spent = true`, advancing
|
|
125
|
+
* `nextNfIndex`, and immediately discarding every stranger prefix.
|
|
126
|
+
*
|
|
127
|
+
* Pre-validates every page header, bounds, and strict contiguity (`pageBase <= runningNfIndex`)
|
|
128
|
+
* BEFORE mutating any note or advancing `nextNfIndex`.
|
|
129
|
+
*/
|
|
130
|
+
ingestNullifierPages(params: {
|
|
131
|
+
laneId: number;
|
|
132
|
+
nfPages: ReadonlyArray<{
|
|
133
|
+
pageSeq: bigint;
|
|
134
|
+
raw: Uint8Array;
|
|
135
|
+
}>;
|
|
136
|
+
maxNfIndex?: bigint;
|
|
137
|
+
}): number;
|
|
138
|
+
/**
|
|
139
|
+
* Prune retained `prevSealedLeaves` on any lane whose `GlobalRootHistory.stable` snapshot
|
|
140
|
+
* (or `ROOT_RING_EPOCH` `RootSnapshotChoice`) has crossed past it.
|
|
141
|
+
* Validates `source` strictly (including `poolId` binding for `DecodedGlobalRootHistory`)
|
|
142
|
+
* before pruning any lane, and refuses to prune on `ROOT_RING_SLOT` (`latest`) snapshots so
|
|
143
|
+
* `prevSealedLeaves` needed for offline `stable` witness builds are never wiped prematurely.
|
|
144
|
+
*/
|
|
145
|
+
pruneSealedBeforeSnapshot(source: DecodedGlobalRootHistory | RootSnapshotChoice): void;
|
|
146
|
+
ingestLanePages(params: {
|
|
147
|
+
fvk: FullViewingKey;
|
|
148
|
+
laneId: number;
|
|
149
|
+
subtreePages: ReadonlyArray<{
|
|
150
|
+
pageSeq: bigint;
|
|
151
|
+
raw: Uint8Array;
|
|
152
|
+
}>;
|
|
153
|
+
memoPages: ReadonlyArray<{
|
|
154
|
+
pageSeq: bigint;
|
|
155
|
+
raw: Uint8Array;
|
|
156
|
+
}>;
|
|
157
|
+
nfPages: ReadonlyArray<{
|
|
158
|
+
pageSeq: bigint;
|
|
159
|
+
raw: Uint8Array;
|
|
160
|
+
}>;
|
|
161
|
+
}): number;
|
|
162
|
+
private _buildSingleWitnessWithSnapshot;
|
|
163
|
+
/**
|
|
164
|
+
* Select ONE shared `RootSnapshotChoice` covering ALL `notes` (preferring `stable`
|
|
165
|
+
* `ROOT_RING_EPOCH`, falling back to `latest` `ROOT_RING_SLOT` when any note is newer OR when
|
|
166
|
+
* the local store lacks pre-seal frontier leaves for an older `stable` page) and build offline
|
|
167
|
+
* 4-ary Depth-20 Merkle witnesses for every note against that shared snapshot.
|
|
168
|
+
*/
|
|
169
|
+
buildWitnessesForNotes(notes: readonly OwnedNote[], rootSource: DecodedGlobalRootHistory | RootSnapshotChoice): {
|
|
170
|
+
snapshot: RootSnapshotChoice;
|
|
171
|
+
superRoot: bigint;
|
|
172
|
+
paths: MerklePath4Ary[];
|
|
173
|
+
rootRingKind: number;
|
|
174
|
+
rootRingIdx: number;
|
|
175
|
+
snapshotSlot: bigint;
|
|
176
|
+
};
|
|
177
|
+
buildWitnessForNote(note: OwnedNote, rootSource: DecodedGlobalRootHistory | RootSnapshotChoice): {
|
|
178
|
+
superRoot: bigint;
|
|
179
|
+
path: MerklePath4Ary;
|
|
180
|
+
rootRingKind: number;
|
|
181
|
+
rootRingIdx: number;
|
|
182
|
+
snapshotSlot: bigint;
|
|
183
|
+
};
|
|
184
|
+
toJSON(): string;
|
|
185
|
+
static fromJSON(json: string): CompactWalletStore;
|
|
186
|
+
}
|