@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/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Audren Contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@audren-xyz/sdk` — Audren TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Unified TypeScript ESM SDK for **Audren** (`AUDRBK6kVkQoEGm3EB7swd34SUPqrHZeNEkB5vZWVSv3`), published on npm under [`@audren-xyz/sdk`](https://www.npmjs.com/package/@audren-xyz/sdk), requiring **Node `>= 22`** (CI pins **`pnpm 10`**), and verified byte-for-byte against [`spec/test-vectors.json`](../../spec/test-vectors.json) and real sBPFv3 `audren.so` in LiteSVM CI.
|
|
4
|
+
|
|
5
|
+
For maintainer, npm publishing, and WASM rebuild rules, see [`AGENTS.md`](AGENTS.md).
|
|
6
|
+
|
|
7
|
+
## Package Entrypoints (`package.json` `exports`)
|
|
8
|
+
|
|
9
|
+
- **`@audren-xyz/sdk`** (`.`): Zero-WASM, `"sideEffects": false` tree-shakeable core for Node.js, Browsers, and Cloudflare Workers — pure-TS Circom BN254 Poseidon (backed by per-width tree-shakeable `POSEIDON_PARAMS_2..6` constants in `src/poseidon-constants.ts`), BIP-350 Bech32m `aud1...` stealth addresses (rejecting non-canonical `spend_pk`, whitespace, and low-order X25519 `view_pk` points), RFC 8439 ChaCha20-Poly1305 versioned `106 B` SoA memos (`34 B` header/AAD + `72 B` ciphertext containing `56 B` plaintext with `14 B` encrypted `paymentId` + `16 B` Poly1305 tag, with X25519 low-order rejection), all 12 canonical PDAs (`audren_*`, including `GlobalRootHistory` `audren_roots`), zero-copy account decoders (`decodeGlobalRootHistory` + `selectRootSnapshotForNotes`), zero-indexer `CompactWalletStore` (bidirectional Rust <-> TS JSON compatible) + Rendezvous (HRW) privacy-first ordinary Solana RPC `getMultipleAccounts` scanner (`syncCompactStoreWithRpc`, default `privacyMode: 'strict'`), `finalized`-first / `confirmed`-fallback `fetchGlobalRootHistory` & batched witness reconstruction (`reconstructWitnessesForNotes` for multi-input spends; `reconstructWitness` for single notes), all 9 instruction builders (`InitPool`, `InitLane`, `OpenPage`, `Deposit`, `InitRootHistory`, `Transact`, `ExecViaEscrow` with `extraWritablePubkeys`, `SetPaused`, `UpdatePool`), zero-crank Auto-`OpenPage` planner (`planAutoOpenPages` / `buildAutoOpenPageInstructions`), bump-aware tight CU limit helpers (`CU_LIMIT_*`, `recommendedOpenPageCuLimit`, `recommendedDepositCuLimit`, `recommendedTransactCuLimit`, `recommendedExecViaEscrowCuLimit`, `computeBumpCuMargin`), Token-2022 helpers (`parseToken2022TransferFeeConfig`, `computeToken2022NetAmount`, `inspectToken2022UnsafeSelfPay`), Solana Transaction v1 (`0x81`) compiler, and the Audren Gateway v1 (`audren-gateway/v1`) / Relayer client (`AudrenRelayClient`, `AudrenRelayError`, `AudrenGatewayClient`, `AudrenGatewayError`, `AUDREN_DEFAULT_RELAY_URL`, `DEFAULT_DEVNET_RELAY_URL`, `AUDREN_DEFAULT_DEVNET_RELAY_URL`, `AUDREN_AUDITED_SWAP_ROUTERS`, `buildSwapInstructions(..., { allowedRouterPrograms })`, supporting `apiKey` / `bearerToken` / custom `headers`, `targetProgramId`, `innocenceProof`, and HTTP `202 sent_unconfirmed`; legacy `quoteSwap` / `buildSwapInstructions` / `getAggregators` proxy methods are `@deprecated` in favor of direct client-side DEX routing).
|
|
10
|
+
- **`@audren-xyz/sdk/idl`** (`./idl`): Generated `AUDREN_CODAMA_IDL` and `AUDREN_ANCHOR_IDL` TypeScript constants (kept off the root `.` barrel so Cloudflare Workers and edge gateways stay lightweight).
|
|
11
|
+
- **`@audren-xyz/sdk/prover`** (`./prover`): Exact Rust-compiled WASM BN254 Groth16 prover (`audren_circuits.wasm`, `17,861` R1CS, 4-ary Depth-20 global MASP, `192 B` proof) running natively in Node.js and Browser Web Workers. `AudrenWasmProver.init()` verifies both `CANONICAL_WASM_SHA256` and `CANONICAL_PK_SHA256` by default (`verifyWasmHash: true`, `verifyPkHash: true`), auto-derives sibling `audren_joinsplit.pk` if only `wasmUrl` is passed, and exposes `prover.dispose()` to zeroize WASM linear memory.
|
|
12
|
+
- **Static asset & raw JSON IDL subpaths:** `@audren-xyz/sdk/wasm/audren_circuits.wasm`, `@audren-xyz/sdk/wasm/audren_joinsplit.pk`, `@audren-xyz/sdk/idl/codama.json`, `@audren-xyz/sdk/idl/anchor.json`.
|
|
13
|
+
|
|
14
|
+
> **Safety defaults to know:**
|
|
15
|
+
> - `syncCompactStoreWithRpc` caps per-call scanning at `MAX_SYNC_PAGES_PER_CALL = 4_096` and returns `{ pool, lanes, discoveredNotes, incomplete }` — loop until `incomplete === false` on large catch-ups.
|
|
16
|
+
> - `buildOpenPageInstruction` defaults `maxPayerDeficit` to `0n` (fail-closed, matching UniFFI Swift/Kotlin); `buildAutoOpenPageInstructions` automatically sets `0n` on proactive pages and `U64_MAX` (or `mandatoryMaxPayerDeficit`) on mandatory rollover pages.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
Install from npm (Node `>= 22`):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @audren-xyz/sdk
|
|
24
|
+
# or: npm install @audren-xyz/sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Upgrading `@audren-xyz/sdk`
|
|
28
|
+
|
|
29
|
+
### For Application, Wallet & Gateway Operators
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Check latest published version on npm
|
|
33
|
+
npm view @audren-xyz/sdk version
|
|
34
|
+
|
|
35
|
+
# Upgrade to the latest compatible release
|
|
36
|
+
pnpm update @audren-xyz/sdk --latest
|
|
37
|
+
# or: npm install @audren-xyz/sdk@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> **Browser WASM & Proving Key pin check:** If a release updates `audren_circuits.wasm` or `audren_joinsplit.pk`, copy the updated files from `node_modules/@audren-xyz/sdk/wasm/` to your static `/wasm/` directory and update any `?v=` cache-busters to match `CANONICAL_WASM_SHA256` / `CANONICAL_PK_SHA256`.
|
|
41
|
+
|
|
42
|
+
### For Contributors Testing Unreleased Local Changes
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/audren-xyz/audren
|
|
46
|
+
pnpm --dir audren/packages/sdk install --frozen-lockfile
|
|
47
|
+
pnpm --dir audren/packages/sdk build
|
|
48
|
+
pnpm add file:./audren/packages/sdk
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For full maintainer npm release & downstream lockfile upgrade instructions across `apps/web`, `apps/relay`, `audren-xyz/gateway`, and `audren-xyz/examples`, see [`AGENTS.md`](AGENTS.md#3-publishing--upgrading-audren-xyzsdk-on-npm).
|
|
52
|
+
|
|
53
|
+
## Quick Example
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import {
|
|
57
|
+
CompactWalletStore,
|
|
58
|
+
deriveKeysFromSeed,
|
|
59
|
+
derivePoolPdaSync,
|
|
60
|
+
deriveRootsPdaSync,
|
|
61
|
+
exportFullViewingKey,
|
|
62
|
+
createSolanaRpcBatchFetcher,
|
|
63
|
+
fetchGlobalRootHistory,
|
|
64
|
+
syncCompactStoreWithRpc,
|
|
65
|
+
} from '@audren-xyz/sdk';
|
|
66
|
+
import { AudrenWasmProver } from '@audren-xyz/sdk/prover';
|
|
67
|
+
|
|
68
|
+
const seed = crypto.getRandomValues(new Uint8Array(32));
|
|
69
|
+
const keys = deriveKeysFromSeed(seed);
|
|
70
|
+
const fvk = exportFullViewingKey(keys);
|
|
71
|
+
const pool = derivePoolPdaSync(0);
|
|
72
|
+
const roots = deriveRootsPdaSync(0);
|
|
73
|
+
|
|
74
|
+
// Ordinary Solana RPC sync — zero indexer and zero crank required
|
|
75
|
+
const store = new CompactWalletStore(0);
|
|
76
|
+
const fetchBatch = createSolanaRpcBatchFetcher(process.env.SOLANA_RPC_URL!);
|
|
77
|
+
let syncRes;
|
|
78
|
+
do {
|
|
79
|
+
syncRes = await syncCompactStoreWithRpc({ store, fvk, fetchBatch });
|
|
80
|
+
} while (syncRes.incomplete);
|
|
81
|
+
|
|
82
|
+
// Fetch finalized GlobalRootHistory (automatically falls back to confirmed for fresh notes)
|
|
83
|
+
const { snapshot } = await fetchGlobalRootHistory({
|
|
84
|
+
rpcUrl: process.env.SOLANA_RPC_URL!,
|
|
85
|
+
poolId: 0,
|
|
86
|
+
requiredNotes: store.unspentNotes(),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Local BN254 Groth16 WASM prover. In Node.js, init() reads the bundled wasm and
|
|
90
|
+
// 3.93 MB proving key; in a browser, serve both files and pass their URLs.
|
|
91
|
+
const prover = await AudrenWasmProver.init();
|
|
92
|
+
// const prover = await AudrenWasmProver.init({ wasmUrl: '/wasm/audren_circuits.wasm', pkUrl: '/wasm/audren_joinsplit.pk' });
|
|
93
|
+
// Call prover.dispose() when done to zeroize WASM linear memory.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Verify Locally
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm --dir packages/sdk install --frozen-lockfile
|
|
100
|
+
pnpm --dir packages/sdk typecheck && pnpm --dir packages/sdk test
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`test/litesvm-driver.mjs` is executed by `cargo test -p audren-ffi --release --test cross_sdk_litesvm -- --nocapture` against real sBPFv3 ELFs (requires `packages/sdk/dist/` built first).
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Audren v1 constants matching `crates/audren-core` byte-for-byte.
|
|
3
|
+
*/
|
|
4
|
+
export declare const AUDREN_PROGRAM_ID = "AUDRBK6kVkQoEGm3EB7swd34SUPqrHZeNEkB5vZWVSv3";
|
|
5
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
6
|
+
export declare const SYSTEM_PROGRAM_ID = "11111111111111111111111111111111";
|
|
7
|
+
export declare const CLASSIC_TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
8
|
+
export declare const TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
9
|
+
export declare const ASSOCIATED_TOKEN_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
10
|
+
export declare const ELGAMAL_REGISTRY_PROGRAM_ID = "regVYJW7tcT8zipN5YiBvHsvR5jXW1uLFxaHSbugABg";
|
|
11
|
+
export declare const WSOL_MINT = "So11111111111111111111111111111111111111112";
|
|
12
|
+
export declare const NUM_LANES = 16;
|
|
13
|
+
export declare const DEFAULT_INITIAL_LANES = 4;
|
|
14
|
+
export declare const NUM_ESCROW_SHARDS = 16;
|
|
15
|
+
export declare const LANE_DEPTH_4ARY = 18;
|
|
16
|
+
export declare const TOTAL_DEPTH_4ARY = 20;
|
|
17
|
+
export declare const SUBTREE_LEVELS_4ARY = 4;
|
|
18
|
+
export declare const SLOT_RING_LEN = 128;
|
|
19
|
+
export declare const EPOCH_RING_LEN = 89;
|
|
20
|
+
export declare const ROOT_ENTRY_LEN = 40;
|
|
21
|
+
export declare const DEFAULT_ROOT_EPOCH_INTERVAL = 32n;
|
|
22
|
+
export declare const MAX_ROOT_EPOCH_INTERVAL = 256n;
|
|
23
|
+
export declare const ROOT_RING_SLOT = 0;
|
|
24
|
+
export declare const ROOT_RING_EPOCH = 1;
|
|
25
|
+
export declare const CU_LIMIT_INIT_POOL = 45000;
|
|
26
|
+
export declare const CU_LIMIT_INIT_LANE = 75000;
|
|
27
|
+
export declare const CU_LIMIT_INIT_ROOT_HISTORY = 75000;
|
|
28
|
+
export declare const CU_LIMIT_OPEN_PAGE = 40000;
|
|
29
|
+
export declare const CU_LIMIT_DEPOSIT = 75000;
|
|
30
|
+
export declare const CU_LIMIT_DEPOSIT_HOOK = 140000;
|
|
31
|
+
export declare const CU_LIMIT_TRANSACT_PRIVATE = 235000;
|
|
32
|
+
export declare const CU_LIMIT_TRANSACT_FULL_EXIT = 165000;
|
|
33
|
+
export declare const CU_LIMIT_TRANSACT_WITHDRAW = 255000;
|
|
34
|
+
export declare const CU_LIMIT_TRANSACT_WITHDRAW_HOOK = 295000;
|
|
35
|
+
export declare const CU_LIMIT_EXEC_VIA_ESCROW_BASE = 285000;
|
|
36
|
+
export declare const MAX_TX_CU_LIMIT = 1400000;
|
|
37
|
+
export declare const POOL_SEED = "audren_pool";
|
|
38
|
+
export declare const VAULT_AUTH_SEED = "audren_vault_auth";
|
|
39
|
+
export declare const LANE_SEED = "audren_lane";
|
|
40
|
+
export declare const LANE_RENT_SEED = "audren_lane_rent";
|
|
41
|
+
export declare const SUBTREE_SEED = "audren_subtree";
|
|
42
|
+
export declare const SUBROOT_SEED = "audren_subroot";
|
|
43
|
+
export declare const MEMO_SEED = "audren_memo";
|
|
44
|
+
export declare const NF_PAGE_SEED = "audren_nf_page";
|
|
45
|
+
export declare const NULLIFIER_SEED = "audren_nf";
|
|
46
|
+
export declare const ROOTS_SEED = "audren_roots";
|
|
47
|
+
export declare const ESCROW_SEED = "audren_escrow";
|
|
48
|
+
export declare const UNWRAP_SEED = "audren_unwrap";
|
|
49
|
+
export declare const TAG_INIT_POOL = 0;
|
|
50
|
+
export declare const TAG_INIT_LANE = 1;
|
|
51
|
+
export declare const TAG_OPEN_PAGE = 2;
|
|
52
|
+
export declare const TAG_DEPOSIT = 3;
|
|
53
|
+
export declare const TAG_INIT_ROOT_HISTORY = 4;
|
|
54
|
+
export declare const TAG_TRANSACT = 5;
|
|
55
|
+
export declare const TAG_EXEC_VIA_ESCROW = 6;
|
|
56
|
+
export declare const TAG_SET_PAUSED = 7;
|
|
57
|
+
export declare const TAG_UPDATE_POOL = 8;
|
|
58
|
+
export declare const INSTRUCTION_COUNT = 9;
|
|
59
|
+
export declare const GROTH16_PROOF_LEN = 192;
|
|
60
|
+
export declare const VK_ID_DEFAULT = 0;
|
|
61
|
+
export declare const CANONICAL_PK_BYTES = 3927280;
|
|
62
|
+
export declare const CANONICAL_PK_SHA256 = "2b22603e466c79b6710e01898dc8b458b09a3ee905b25db996f0c59e76187ee4";
|
|
63
|
+
export declare const CANONICAL_WASM_BYTES = 2440431;
|
|
64
|
+
export declare const CANONICAL_WASM_SHA256 = "b1316246118753e28d68442efb7412ebf20a65d80d4ced5a303705b76e627ab7";
|
|
65
|
+
export declare const OPEN_PAGE_KIND_SUBTREE = 0;
|
|
66
|
+
export declare const OPEN_PAGE_KIND_SUBROOT = 1;
|
|
67
|
+
export declare const OPEN_PAGE_KIND_MEMO = 2;
|
|
68
|
+
export declare const OPEN_PAGE_KIND_NULLIFIER = 3;
|
|
69
|
+
export declare const OPEN_PAGE_DATA_LEN = 22;
|
|
70
|
+
export declare const OPEN_PAGE_WIRE_LEN = 23;
|
|
71
|
+
export declare const OPEN_PAGE_SUBTREE_LOOKAHEAD_SLOT = 230n;
|
|
72
|
+
export declare const OPEN_PAGE_SUBROOT_LOOKAHEAD_SLOT = 280n;
|
|
73
|
+
export declare const OPEN_PAGE_MEMO_LOOKAHEAD_SLOT = 86n;
|
|
74
|
+
export declare const OPEN_PAGE_NF_LOOKAHEAD_SLOT = 540n;
|
|
75
|
+
export declare const DEPOSIT_FLAG_FEE_FROM_AMOUNT: number;
|
|
76
|
+
export declare const DEPOSIT_FLAG_NATIVE_SOL: number;
|
|
77
|
+
export declare const ASSET_MODE_PRIVATE = 0;
|
|
78
|
+
export declare const ASSET_MODE_PUBLIC = 1;
|
|
79
|
+
export declare const WITHDRAW_FLAG_UNWRAP_WSOL: number;
|
|
80
|
+
export declare const EXEC_FLAG_FEE_ON_OUTPUT: number;
|
|
81
|
+
export declare const UPDATE_POOL_PARAMS = 0;
|
|
82
|
+
export declare const UPDATE_POOL_PROPOSE_AUTHORITY = 1;
|
|
83
|
+
export declare const UPDATE_POOL_ACCEPT_AUTHORITY = 2;
|
|
84
|
+
export declare const UPDATE_POOL_RENOUNCE_AUTHORITY = 3;
|
|
85
|
+
export declare const ASSET_ID_DOMAIN = "audren/v1/asset";
|
|
86
|
+
export declare const CTX_DOMAIN_TRANSACT = "audren/v1/ctx";
|
|
87
|
+
export declare const CTX_DOMAIN_EXEC_VIA_ESCROW = "audren/v1/exec_ctx";
|
|
88
|
+
export declare const CTX_DOMAIN_ROUTER_ACCOUNTS = "audren/v1/router_accs";
|
|
89
|
+
export declare const KDF_DOMAIN_VIEW_TAG = "audren/v1/vt";
|
|
90
|
+
export declare const KDF_DOMAIN_MEMO_KEY = "audren/v1/key";
|
|
91
|
+
export declare const KDF_DOMAIN_MEMO_NONCE = "audren/v1/nonce";
|
|
92
|
+
export declare const KDF_DOMAIN_TWEAK = "audren/v1/tweak";
|
|
93
|
+
export declare const KDF_DOMAIN_BLIND = "audren/v1/blind";
|
|
94
|
+
export declare const KDF_DOMAIN_DYN_TWEAK = "audren/v1/dyn_tweak";
|
|
95
|
+
export declare const KDF_DOMAIN_DYN_BLIND = "audren/v1/dyn_blind";
|
|
96
|
+
export declare const KDF_DOMAIN_DYN_MASK = "audren/v1/dyn_mask";
|
|
97
|
+
export declare const DOMAIN_PK = 1n;
|
|
98
|
+
export declare const DOMAIN_STEALTH = 2n;
|
|
99
|
+
export declare const DOMAIN_NOTE = 3n;
|
|
100
|
+
export declare const DOMAIN_NULLIFIER = 4n;
|
|
101
|
+
export declare const DOMAIN_DUMMY_NF = 5n;
|
|
102
|
+
export declare const DOMAIN_PUB_HASH_A = 7n;
|
|
103
|
+
export declare const DOMAIN_PUB_HASH_B = 8n;
|
|
104
|
+
export declare const DOMAIN_PUB_HASH_FINAL = 9n;
|
|
105
|
+
export declare const DOMAIN_NK = 10n;
|
|
106
|
+
export declare const MAX_CPI_ACCOUNT_ALLOC = 10240;
|
|
107
|
+
export declare const SUBTREE_LEAVES = 256;
|
|
108
|
+
export declare const SUBROOTS_PER_PAGE = 300;
|
|
109
|
+
export declare const MEMO_NOTES_PER_PAGE = 96;
|
|
110
|
+
export declare const MEMO_PLAINTEXT_LEN = 56;
|
|
111
|
+
export declare const MEMO_VERSION_V1 = 1;
|
|
112
|
+
export declare const MEMO_PAYMENT_ID_LEN = 14;
|
|
113
|
+
export declare const MEMO_CT_LEN = 72;
|
|
114
|
+
export declare const MEMO_ENTRY_WIRE_LEN = 106;
|
|
115
|
+
export declare const DYN_MEMO_HEAD_LEN = 34;
|
|
116
|
+
export declare const NF_PREFIX_LEN = 16;
|
|
117
|
+
export declare const NF_PER_PAGE = 600;
|
|
118
|
+
export declare const POOL_MAGIC = "AUD1PL01";
|
|
119
|
+
export declare const LANE_RENT_MAGIC = "AUD1RV01";
|
|
120
|
+
export declare const LANE_MAGIC = "AUD1LN01";
|
|
121
|
+
export declare const SUBTREE_MAGIC = "AUD1SB01";
|
|
122
|
+
export declare const SUBROOT_MAGIC = "AUD1SR01";
|
|
123
|
+
export declare const MEMO_MAGIC = "AUD1MM01";
|
|
124
|
+
export declare const NF_PAGE_MAGIC = "AUD1NF01";
|
|
125
|
+
export declare const ROOTS_MAGIC = "AUD1RT01";
|
|
126
|
+
export declare const DYN_MEMO_MAGIC = "AUD1DYN1";
|
|
127
|
+
export declare const POOL_STATE_LEN = 128;
|
|
128
|
+
export declare const SENTINEL_LEN = 16;
|
|
129
|
+
export declare const LANE_STATE_LEN = 1824;
|
|
130
|
+
export declare const SUBTREE_PAGE_LEN = 8256;
|
|
131
|
+
export declare const SUBROOT_PAGE_LEN = 9664;
|
|
132
|
+
export declare const MEMO_PAGE_LEN = 10240;
|
|
133
|
+
export declare const NF_PAGE_LEN = 9664;
|
|
134
|
+
export declare const ROOT_SNAPSHOT_LEN = 672;
|
|
135
|
+
export declare const ROOT_HISTORY_LEN = 10216;
|
|
136
|
+
export declare const SN_OFF_MAGIC = 0;
|
|
137
|
+
export declare const SN_OFF_POOL_ID = 8;
|
|
138
|
+
export declare const SN_OFF_LANE_ID = 12;
|
|
139
|
+
export declare const SN_OFF_BUMP = 13;
|
|
140
|
+
export declare const PL_OFF_MAGIC = 0;
|
|
141
|
+
export declare const PL_OFF_VERSION = 8;
|
|
142
|
+
export declare const PL_OFF_BUMP = 9;
|
|
143
|
+
export declare const PL_OFF_PAUSED = 10;
|
|
144
|
+
export declare const PL_OFF_ACTIVE_LANES = 11;
|
|
145
|
+
export declare const PL_OFF_POOL_ID = 12;
|
|
146
|
+
export declare const PL_OFF_ROOT_EPOCH_INTERVAL = 16;
|
|
147
|
+
export declare const PL_OFF_RESERVED_24 = 24;
|
|
148
|
+
export declare const PL_OFF_AUTHORITY = 32;
|
|
149
|
+
export declare const PL_OFF_VAULT_AUTH_BUMP = 64;
|
|
150
|
+
export declare const PL_OFF_NOTE_RENT_FEE = 72;
|
|
151
|
+
export declare const PL_OFF_NF_RENT_FEE = 80;
|
|
152
|
+
export declare const PL_OFF_PENDING_AUTHORITY = 88;
|
|
153
|
+
export declare const LN_OFF_MAGIC = 0;
|
|
154
|
+
export declare const LN_OFF_VERSION = 8;
|
|
155
|
+
export declare const LN_OFF_LANE_ID = 9;
|
|
156
|
+
export declare const LN_OFF_BUMP = 10;
|
|
157
|
+
export declare const LN_OFF_RENT_BUMP = 11;
|
|
158
|
+
export declare const LN_OFF_POOL_ID = 12;
|
|
159
|
+
export declare const LN_OFF_NEXT_LEAF = 16;
|
|
160
|
+
export declare const LN_OFF_NF_COUNT = 24;
|
|
161
|
+
export declare const LN_OFF_CURRENT_ROOT = 64;
|
|
162
|
+
export declare const LN_OFF_FRONTIER = 96;
|
|
163
|
+
export declare const SB_OFF_MAGIC = 0;
|
|
164
|
+
export declare const SB_OFF_LANE_ID = 8;
|
|
165
|
+
export declare const SB_OFF_BUMP = 9;
|
|
166
|
+
export declare const SB_OFF_COUNT = 10;
|
|
167
|
+
export declare const SB_OFF_POOL_ID = 12;
|
|
168
|
+
export declare const SB_OFF_PAGE_SEQ = 16;
|
|
169
|
+
export declare const SB_OFF_LEAVES = 64;
|
|
170
|
+
export declare const SR_OFF_MAGIC = 0;
|
|
171
|
+
export declare const SR_OFF_LANE_ID = 8;
|
|
172
|
+
export declare const SR_OFF_BUMP = 9;
|
|
173
|
+
export declare const SR_OFF_COUNT = 10;
|
|
174
|
+
export declare const SR_OFF_POOL_ID = 12;
|
|
175
|
+
export declare const SR_OFF_ROOT_PAGE_SEQ = 16;
|
|
176
|
+
export declare const SR_OFF_ROOTS = 64;
|
|
177
|
+
export declare const MM_OFF_MAGIC = 0;
|
|
178
|
+
export declare const MM_OFF_LANE_ID = 8;
|
|
179
|
+
export declare const MM_OFF_BUMP = 9;
|
|
180
|
+
export declare const MM_OFF_COUNT = 10;
|
|
181
|
+
export declare const MM_OFF_POOL_ID = 12;
|
|
182
|
+
export declare const MM_OFF_PAGE_SEQ = 16;
|
|
183
|
+
export declare const MM_OFF_CREATED_SLOT = 24;
|
|
184
|
+
export declare const MM_OFF_CLOSED_SLOT = 32;
|
|
185
|
+
export declare const MM_OFF_VIEW_TAGS = 64;
|
|
186
|
+
export declare const MM_OFF_EPHEMERAL_PKS = 256;
|
|
187
|
+
export declare const MM_OFF_CIPHERTEXTS = 3328;
|
|
188
|
+
export declare const MEMO_PAGE_HEADER_LEN = 64;
|
|
189
|
+
export declare const MEMO_PAGE_SCAN_SLICE_LEN = 3328;
|
|
190
|
+
export declare const NF_OFF_MAGIC = 0;
|
|
191
|
+
export declare const NF_OFF_LANE_ID = 8;
|
|
192
|
+
export declare const NF_OFF_BUMP = 9;
|
|
193
|
+
export declare const NF_OFF_COUNT = 10;
|
|
194
|
+
export declare const NF_OFF_POOL_ID = 12;
|
|
195
|
+
export declare const NF_OFF_PAGE_SEQ = 16;
|
|
196
|
+
export declare const NF_OFF_CREATED_SLOT = 24;
|
|
197
|
+
export declare const NF_OFF_CLOSED_SLOT = 32;
|
|
198
|
+
export declare const NF_OFF_PREFIXES = 64;
|
|
199
|
+
export declare const NF_PAGE_HEADER_LEN = 64;
|
|
200
|
+
export declare const RT_OFF_MAGIC = 0;
|
|
201
|
+
export declare const RT_OFF_VERSION = 8;
|
|
202
|
+
export declare const RT_OFF_BUMP = 9;
|
|
203
|
+
export declare const RT_OFF_SLOT_CURSOR = 10;
|
|
204
|
+
export declare const RT_OFF_POOL_ID = 12;
|
|
205
|
+
export declare const RT_OFF_EPOCH_CURSOR = 16;
|
|
206
|
+
export declare const RT_OFF_SLOT_COUNT = 18;
|
|
207
|
+
export declare const RT_OFF_EPOCH_COUNT = 20;
|
|
208
|
+
export declare const RT_OFF_SAME_SLOT_BUMPED = 22;
|
|
209
|
+
export declare const RT_OFF_LATEST_SLOT = 24;
|
|
210
|
+
export declare const RT_OFF_STABLE_EPOCH_ID = 32;
|
|
211
|
+
export declare const RT_OFF_STABLE_SLOT = 40;
|
|
212
|
+
export declare const RT_OFF_EPOCH_INTERVAL = 48;
|
|
213
|
+
export declare const RT_OFF_GROUP_ROOTS = 64;
|
|
214
|
+
export declare const RT_OFF_LATEST_SUPER_ROOT = 192;
|
|
215
|
+
export declare const RT_OFF_LATEST_LANE_ROOTS = 224;
|
|
216
|
+
export declare const RT_OFF_LATEST_LANE_COUNTS = 736;
|
|
217
|
+
export declare const RT_OFF_STABLE_SUPER_ROOT = 864;
|
|
218
|
+
export declare const RT_OFF_STABLE_LANE_ROOTS = 896;
|
|
219
|
+
export declare const RT_OFF_STABLE_LANE_COUNTS = 1408;
|
|
220
|
+
export declare const RT_OFF_SLOT_RING = 1536;
|
|
221
|
+
export declare const RT_OFF_EPOCH_RING = 6656;
|
|
222
|
+
/** BN254 scalar field modulus r */
|
|
223
|
+
export declare const BN254_FR_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
224
|
+
export declare const ZERO_HASHES_4ARY: readonly bigint[];
|
|
225
|
+
export declare const AUDREN_ERRORS: Record<number, string>;
|
|
226
|
+
export declare const WITNESS_INPUT_BYTES = 2077;
|
|
227
|
+
export declare const WITNESS_OUTPUT_BYTES = 104;
|
|
228
|
+
export declare const WITNESS_TOTAL_BYTES = 4611;
|
|
229
|
+
export declare const PROVE_OUTPUT_BYTES = 384;
|