@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/keys.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Audren key derivation, Mode 1 `SelectiveDisclosureProof`,
|
|
3
|
+
* Mode 2 read-only `FullViewingKey` (`spendPk`, `nk`, `viewSk`, `viewPk`),
|
|
4
|
+
* and deterministic `DefiSessionKeypair` matching `crates/client/src/keys.rs` byte-for-byte.
|
|
5
|
+
*/
|
|
6
|
+
export interface AudrenKeys {
|
|
7
|
+
spendSk: bigint;
|
|
8
|
+
spendSkBytes: Uint8Array;
|
|
9
|
+
spendPk: bigint;
|
|
10
|
+
spendPkBytes: Uint8Array;
|
|
11
|
+
nk: bigint;
|
|
12
|
+
nkBytes: Uint8Array;
|
|
13
|
+
viewSk: Uint8Array;
|
|
14
|
+
viewPk: Uint8Array;
|
|
15
|
+
address: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FullViewingKey {
|
|
18
|
+
spendPk: Uint8Array;
|
|
19
|
+
nk: Uint8Array;
|
|
20
|
+
viewSk: Uint8Array;
|
|
21
|
+
viewPk: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Deterministic Solana Ed25519 keypair for stateful account-bound DeFi protocols
|
|
25
|
+
* (borrowing, perp margin, CLMM positions).
|
|
26
|
+
*
|
|
27
|
+
* **Privacy boundary:** Each `sessionIndex` is a pseudonymous Solana wallet unlinkable to the
|
|
28
|
+
* user's primary public wallet or other sessions when funded via relayed `Transact` Withdraw
|
|
29
|
+
* and swept back via zero-dust `Deposit` (`DEPOSIT_FLAG_NATIVE_SOL | DEPOSIT_FLAG_FEE_FROM_AMOUNT`).
|
|
30
|
+
* All positions and transactions executed BY that session wallet on external DeFi protocols remain
|
|
31
|
+
* public on Solana.
|
|
32
|
+
*/
|
|
33
|
+
export interface DefiSessionKeypair {
|
|
34
|
+
sessionIndex: number;
|
|
35
|
+
secretSeed: Uint8Array;
|
|
36
|
+
pubkey: Uint8Array;
|
|
37
|
+
pubkeyBase58: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SelectiveDisclosureProof {
|
|
40
|
+
poolId: number;
|
|
41
|
+
laneId: number;
|
|
42
|
+
leafIndex: bigint;
|
|
43
|
+
stealthOwner: Uint8Array;
|
|
44
|
+
mint: Uint8Array;
|
|
45
|
+
amount: bigint;
|
|
46
|
+
blinding: Uint8Array;
|
|
47
|
+
commitment: Uint8Array;
|
|
48
|
+
}
|
|
49
|
+
export declare function deriveKeysFromSeed(seed32: Uint8Array): AudrenKeys;
|
|
50
|
+
export declare function deriveSubaccountKeys(masterSeed32: Uint8Array, accountIndex: number): AudrenKeys;
|
|
51
|
+
export declare function exportFullViewingKey(keys: AudrenKeys): FullViewingKey;
|
|
52
|
+
export declare function deriveDefiSessionKeypair(masterSeed32: Uint8Array, sessionIndex: number): DefiSessionKeypair;
|
|
53
|
+
export declare function fvkStealthOwner(fvk: FullViewingKey, tweak: bigint): bigint;
|
|
54
|
+
export declare function fvkRealNullifier(fvk: FullViewingKey, noteCm: bigint, globalLeafIndex: bigint): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Verify a Mode 1 per-transaction `SelectiveDisclosureProof` against an on-chain
|
|
57
|
+
* `SubtreePage` leaf commitment in 1 Poseidon hash (reveals zero keys).
|
|
58
|
+
*
|
|
59
|
+
* Note: Mode 1 proves commitment preimage opening (`mint` + `amount` at a leaf), not exclusive
|
|
60
|
+
* recipient ownership (any party who knows the opening preimage, such as the sender or a public
|
|
61
|
+
* observer of `Deposit`/`ExecViaEscrow`, can construct the same opening).
|
|
62
|
+
*
|
|
63
|
+
* Enforces strict field bounds (`0 <= amount <= u64::MAX`, `0 <= leafIndex < MAX_LEAVES_PER_LANE`,
|
|
64
|
+
* valid `u32` `poolId`, `0 <= laneId < NUM_LANES`, exact 32-byte arrays) so modular field aliasing
|
|
65
|
+
* (`amount + k * r`) is unconditionally rejected.
|
|
66
|
+
*/
|
|
67
|
+
export declare function verifySelectiveDisclosureProof(proof: SelectiveDisclosureProof, onchainSubtreeLeaf: Uint8Array): boolean;
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Audren key derivation, Mode 1 `SelectiveDisclosureProof`,
|
|
3
|
+
* Mode 2 read-only `FullViewingKey` (`spendPk`, `nk`, `viewSk`, `viewPk`),
|
|
4
|
+
* and deterministic `DefiSessionKeypair` matching `crates/client/src/keys.rs` byte-for-byte.
|
|
5
|
+
*/
|
|
6
|
+
import { ed25519, x25519 } from '@noble/curves/ed25519.js';
|
|
7
|
+
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
8
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
9
|
+
import { NUM_LANES } from './constants.js';
|
|
10
|
+
import { MAX_LEAVES_PER_LANE } from './layout.js';
|
|
11
|
+
import { base58Encode, formatAudrenAddress } from './pda.js';
|
|
12
|
+
import { bytes32ToFrMasked, computeNoteCommitment, computeRealNullifier, deriveAssetId, deriveNullifierKey, deriveSpendPk, deriveStealthOwner, frFromBeBytesStrict, frToBeBytes, } from './poseidon.js';
|
|
13
|
+
const utf8Encoder = new TextEncoder();
|
|
14
|
+
const U32_MAX = 0xffff_ffff;
|
|
15
|
+
const U64_MAX = 0xffffffffffffffffn;
|
|
16
|
+
function u32le(n) {
|
|
17
|
+
if (!Number.isInteger(n) || n < 0 || n > U32_MAX) {
|
|
18
|
+
throw new RangeError(`u32 value out of range (expected 0..=${U32_MAX}), got ${n}`);
|
|
19
|
+
}
|
|
20
|
+
const out = new Uint8Array(4);
|
|
21
|
+
new DataView(out.buffer).setUint32(0, n, true);
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
const NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom');
|
|
25
|
+
function attachSecretRedaction(obj, summary, label) {
|
|
26
|
+
Object.defineProperty(obj, 'toJSON', {
|
|
27
|
+
value: () => summary(),
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true,
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(obj, NODE_INSPECT_CUSTOM, {
|
|
32
|
+
value: () => `${label} ${JSON.stringify(summary())}`,
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true,
|
|
35
|
+
});
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
export function deriveKeysFromSeed(seed32) {
|
|
39
|
+
if (!(seed32 instanceof Uint8Array) || seed32.byteLength !== 32) {
|
|
40
|
+
throw new RangeError(`Master seed must be 32 bytes (Uint8Array), got ${seed32 instanceof Uint8Array ? seed32.byteLength : String(seed32)}`);
|
|
41
|
+
}
|
|
42
|
+
const salt = utf8Encoder.encode('audren/v1/root');
|
|
43
|
+
const spendRaw = hkdf(sha256, seed32, salt, utf8Encoder.encode('audren/v1/spend_sk'), 32);
|
|
44
|
+
let spendSk;
|
|
45
|
+
try {
|
|
46
|
+
spendSk = bytes32ToFrMasked(spendRaw);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
spendRaw.fill(0);
|
|
50
|
+
}
|
|
51
|
+
const spendPk = deriveSpendPk(spendSk);
|
|
52
|
+
const nk = deriveNullifierKey(spendSk);
|
|
53
|
+
const viewSk = hkdf(sha256, seed32, salt, utf8Encoder.encode('audren/v1/view_sk'), 32);
|
|
54
|
+
const viewPk = x25519.getPublicKey(viewSk);
|
|
55
|
+
const spendSkBytes = frToBeBytes(spendSk);
|
|
56
|
+
const spendPkBytes = frToBeBytes(spendPk);
|
|
57
|
+
const nkBytes = frToBeBytes(nk);
|
|
58
|
+
const address = formatAudrenAddress(spendPkBytes, viewPk);
|
|
59
|
+
return attachSecretRedaction({
|
|
60
|
+
spendSk,
|
|
61
|
+
spendSkBytes,
|
|
62
|
+
spendPk,
|
|
63
|
+
spendPkBytes,
|
|
64
|
+
nk,
|
|
65
|
+
nkBytes,
|
|
66
|
+
viewSk,
|
|
67
|
+
viewPk,
|
|
68
|
+
address,
|
|
69
|
+
}, () => ({ address, spendSk: '[REDACTED]', nk: '[REDACTED]', viewSk: '[REDACTED]' }), 'AudrenKeys');
|
|
70
|
+
}
|
|
71
|
+
export function deriveSubaccountKeys(masterSeed32, accountIndex) {
|
|
72
|
+
if (!(masterSeed32 instanceof Uint8Array) || masterSeed32.byteLength !== 32) {
|
|
73
|
+
throw new RangeError(`Master seed must be 32 bytes (Uint8Array), got ${masterSeed32 instanceof Uint8Array ? masterSeed32.byteLength : String(masterSeed32)}`);
|
|
74
|
+
}
|
|
75
|
+
if (!Number.isInteger(accountIndex) || accountIndex < 0 || accountIndex > U32_MAX) {
|
|
76
|
+
throw new RangeError(`accountIndex must be a u32 integer in 0..=${U32_MAX}, got ${accountIndex}`);
|
|
77
|
+
}
|
|
78
|
+
if (accountIndex === 0)
|
|
79
|
+
return deriveKeysFromSeed(masterSeed32);
|
|
80
|
+
const child = hkdf(sha256, masterSeed32, utf8Encoder.encode('audren/v1/subaccount'), u32le(accountIndex), 32);
|
|
81
|
+
try {
|
|
82
|
+
return deriveKeysFromSeed(child);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
child.fill(0);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function exportFullViewingKey(keys) {
|
|
89
|
+
if (!keys ||
|
|
90
|
+
typeof keys !== 'object' ||
|
|
91
|
+
!(keys.spendPkBytes instanceof Uint8Array) ||
|
|
92
|
+
keys.spendPkBytes.byteLength !== 32 ||
|
|
93
|
+
!(keys.nkBytes instanceof Uint8Array) ||
|
|
94
|
+
keys.nkBytes.byteLength !== 32 ||
|
|
95
|
+
!(keys.viewSk instanceof Uint8Array) ||
|
|
96
|
+
keys.viewSk.byteLength !== 32 ||
|
|
97
|
+
!(keys.viewPk instanceof Uint8Array) ||
|
|
98
|
+
keys.viewPk.byteLength !== 32) {
|
|
99
|
+
throw new RangeError('keys must provide 32-byte Uint8Array spendPkBytes, nkBytes, viewSk, and viewPk');
|
|
100
|
+
}
|
|
101
|
+
const address = formatAudrenAddress(keys.spendPkBytes, keys.viewPk);
|
|
102
|
+
return attachSecretRedaction({
|
|
103
|
+
spendPk: new Uint8Array(keys.spendPkBytes),
|
|
104
|
+
nk: new Uint8Array(keys.nkBytes),
|
|
105
|
+
viewSk: new Uint8Array(keys.viewSk),
|
|
106
|
+
viewPk: new Uint8Array(keys.viewPk),
|
|
107
|
+
}, () => ({ address, nk: '[REDACTED]', viewSk: '[REDACTED]' }), 'FullViewingKey');
|
|
108
|
+
}
|
|
109
|
+
export function deriveDefiSessionKeypair(masterSeed32, sessionIndex) {
|
|
110
|
+
if (!(masterSeed32 instanceof Uint8Array) || masterSeed32.byteLength !== 32) {
|
|
111
|
+
throw new RangeError(`Master seed must be 32 bytes (Uint8Array), got ${masterSeed32 instanceof Uint8Array ? masterSeed32.byteLength : String(masterSeed32)}`);
|
|
112
|
+
}
|
|
113
|
+
if (!Number.isInteger(sessionIndex) || sessionIndex < 0 || sessionIndex > U32_MAX) {
|
|
114
|
+
throw new RangeError(`sessionIndex must be a u32 integer in 0..=${U32_MAX}, got ${sessionIndex}`);
|
|
115
|
+
}
|
|
116
|
+
const secretSeed = hkdf(sha256, masterSeed32, utf8Encoder.encode('audren/v1/defi_session'), u32le(sessionIndex), 32);
|
|
117
|
+
const pubkey = ed25519.getPublicKey(secretSeed);
|
|
118
|
+
const pubkeyBase58 = base58Encode(pubkey);
|
|
119
|
+
return attachSecretRedaction({
|
|
120
|
+
sessionIndex,
|
|
121
|
+
secretSeed,
|
|
122
|
+
pubkey,
|
|
123
|
+
pubkeyBase58,
|
|
124
|
+
}, () => ({ sessionIndex, pubkeyBase58, secretSeed: '[REDACTED]' }), 'DefiSessionKeypair');
|
|
125
|
+
}
|
|
126
|
+
export function fvkStealthOwner(fvk, tweak) {
|
|
127
|
+
if (!fvk || typeof fvk !== 'object') {
|
|
128
|
+
throw new RangeError('fvk must be an object');
|
|
129
|
+
}
|
|
130
|
+
return deriveStealthOwner(frFromBeBytesStrict(fvk.spendPk), tweak);
|
|
131
|
+
}
|
|
132
|
+
export function fvkRealNullifier(fvk, noteCm, globalLeafIndex) {
|
|
133
|
+
if (!fvk || typeof fvk !== 'object') {
|
|
134
|
+
throw new RangeError('fvk must be an object');
|
|
135
|
+
}
|
|
136
|
+
return frToBeBytes(computeRealNullifier(frFromBeBytesStrict(fvk.nk), noteCm, globalLeafIndex));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Verify a Mode 1 per-transaction `SelectiveDisclosureProof` against an on-chain
|
|
140
|
+
* `SubtreePage` leaf commitment in 1 Poseidon hash (reveals zero keys).
|
|
141
|
+
*
|
|
142
|
+
* Note: Mode 1 proves commitment preimage opening (`mint` + `amount` at a leaf), not exclusive
|
|
143
|
+
* recipient ownership (any party who knows the opening preimage, such as the sender or a public
|
|
144
|
+
* observer of `Deposit`/`ExecViaEscrow`, can construct the same opening).
|
|
145
|
+
*
|
|
146
|
+
* Enforces strict field bounds (`0 <= amount <= u64::MAX`, `0 <= leafIndex < MAX_LEAVES_PER_LANE`,
|
|
147
|
+
* valid `u32` `poolId`, `0 <= laneId < NUM_LANES`, exact 32-byte arrays) so modular field aliasing
|
|
148
|
+
* (`amount + k * r`) is unconditionally rejected.
|
|
149
|
+
*/
|
|
150
|
+
export function verifySelectiveDisclosureProof(proof, onchainSubtreeLeaf) {
|
|
151
|
+
if (!proof ||
|
|
152
|
+
typeof proof !== 'object' ||
|
|
153
|
+
!(onchainSubtreeLeaf instanceof Uint8Array) ||
|
|
154
|
+
!(proof.stealthOwner instanceof Uint8Array) ||
|
|
155
|
+
!(proof.mint instanceof Uint8Array) ||
|
|
156
|
+
!(proof.blinding instanceof Uint8Array) ||
|
|
157
|
+
!(proof.commitment instanceof Uint8Array) ||
|
|
158
|
+
onchainSubtreeLeaf.byteLength !== 32 ||
|
|
159
|
+
proof.stealthOwner.byteLength !== 32 ||
|
|
160
|
+
proof.mint.byteLength !== 32 ||
|
|
161
|
+
proof.blinding.byteLength !== 32 ||
|
|
162
|
+
proof.commitment.byteLength !== 32) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (!Number.isInteger(proof.poolId) || proof.poolId < 0 || proof.poolId > U32_MAX) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (!Number.isInteger(proof.laneId) || proof.laneId < 0 || proof.laneId >= NUM_LANES) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (typeof proof.leafIndex !== 'bigint' ||
|
|
172
|
+
proof.leafIndex < 0n ||
|
|
173
|
+
proof.leafIndex >= MAX_LEAVES_PER_LANE) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (typeof proof.amount !== 'bigint' || proof.amount < 0n || proof.amount > U64_MAX) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
const stealth = frFromBeBytesStrict(proof.stealthOwner);
|
|
181
|
+
const blinding = frFromBeBytesStrict(proof.blinding);
|
|
182
|
+
const assetId = deriveAssetId(proof.mint);
|
|
183
|
+
const computed = frToBeBytes(computeNoteCommitment(stealth, assetId, proof.amount, blinding));
|
|
184
|
+
for (let i = 0; i < 32; i++) {
|
|
185
|
+
if (computed[i] !== proof.commitment[i] || computed[i] !== onchainSubtreeLeaf[i]) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-copy Audren account decoders matching `crates/audren-core/src/layout.rs` byte-for-byte.
|
|
3
|
+
*/
|
|
4
|
+
/** Maximum note commitments per lane (`4^18 = 2^36 = 68,719,476,736`). */
|
|
5
|
+
export declare const MAX_LEAVES_PER_LANE: bigint;
|
|
6
|
+
export interface DecodedPoolState {
|
|
7
|
+
version: number;
|
|
8
|
+
bump: number;
|
|
9
|
+
paused: boolean;
|
|
10
|
+
activeLanes: number;
|
|
11
|
+
poolId: number;
|
|
12
|
+
rootEpochInterval: bigint;
|
|
13
|
+
authority: string;
|
|
14
|
+
authorityBytes: Uint8Array;
|
|
15
|
+
vaultAuthBump: number;
|
|
16
|
+
noteRentFee: bigint;
|
|
17
|
+
nfRentFee: bigint;
|
|
18
|
+
pendingAuthority: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
export interface DecodedLaneHeader {
|
|
21
|
+
version: number;
|
|
22
|
+
laneId: number;
|
|
23
|
+
bump: number;
|
|
24
|
+
rentBump: number;
|
|
25
|
+
poolId: number;
|
|
26
|
+
nextLeaf: bigint;
|
|
27
|
+
nfCount: bigint;
|
|
28
|
+
currentRoot: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
export interface RootEntry {
|
|
31
|
+
superRoot: Uint8Array;
|
|
32
|
+
slot: bigint;
|
|
33
|
+
}
|
|
34
|
+
export interface RootSnapshotChoice {
|
|
35
|
+
ringKind: number;
|
|
36
|
+
ringIdx: number;
|
|
37
|
+
slot: bigint;
|
|
38
|
+
superRoot: Uint8Array;
|
|
39
|
+
laneRoots: Uint8Array[];
|
|
40
|
+
laneCounts: bigint[];
|
|
41
|
+
}
|
|
42
|
+
export interface DecodedGlobalRootHistory {
|
|
43
|
+
version: number;
|
|
44
|
+
bump: number;
|
|
45
|
+
slotCursor: number;
|
|
46
|
+
poolId: number;
|
|
47
|
+
epochCursor: number;
|
|
48
|
+
slotCount: number;
|
|
49
|
+
epochCount: number;
|
|
50
|
+
sameSlotBumped: boolean;
|
|
51
|
+
latestSlot: bigint;
|
|
52
|
+
stableEpochId: bigint;
|
|
53
|
+
stableSlot: bigint;
|
|
54
|
+
epochInterval: bigint;
|
|
55
|
+
groupRoots: Uint8Array[];
|
|
56
|
+
latestSuperRoot: Uint8Array;
|
|
57
|
+
latestLaneRoots: Uint8Array[];
|
|
58
|
+
latestLaneCounts: bigint[];
|
|
59
|
+
stableSuperRoot: Uint8Array;
|
|
60
|
+
stableLaneRoots: Uint8Array[];
|
|
61
|
+
stableLaneCounts: bigint[];
|
|
62
|
+
slotRing: RootEntry[];
|
|
63
|
+
epochRing: RootEntry[];
|
|
64
|
+
}
|
|
65
|
+
export interface DecodedSubtreePage {
|
|
66
|
+
laneId: number;
|
|
67
|
+
bump: number;
|
|
68
|
+
count: number;
|
|
69
|
+
poolId: number;
|
|
70
|
+
pageSeq: bigint;
|
|
71
|
+
leaves: Uint8Array[];
|
|
72
|
+
}
|
|
73
|
+
export interface DecodedSubtreeRootPage {
|
|
74
|
+
laneId: number;
|
|
75
|
+
bump: number;
|
|
76
|
+
count: number;
|
|
77
|
+
poolId: number;
|
|
78
|
+
rootPageSeq: bigint;
|
|
79
|
+
roots: Uint8Array[];
|
|
80
|
+
}
|
|
81
|
+
export interface DecodedMemoEntry {
|
|
82
|
+
viewTag: Uint8Array;
|
|
83
|
+
ephemeralPk: Uint8Array;
|
|
84
|
+
ciphertext: Uint8Array;
|
|
85
|
+
}
|
|
86
|
+
export interface DecodedMemoPage {
|
|
87
|
+
laneId: number;
|
|
88
|
+
bump: number;
|
|
89
|
+
count: number;
|
|
90
|
+
poolId: number;
|
|
91
|
+
pageSeq: bigint;
|
|
92
|
+
createdSlot: bigint;
|
|
93
|
+
closedSlot: bigint;
|
|
94
|
+
entries: DecodedMemoEntry[];
|
|
95
|
+
}
|
|
96
|
+
export interface DecodedMemoPageHeader {
|
|
97
|
+
laneId: number;
|
|
98
|
+
bump: number;
|
|
99
|
+
count: number;
|
|
100
|
+
poolId: number;
|
|
101
|
+
pageSeq: bigint;
|
|
102
|
+
createdSlot: bigint;
|
|
103
|
+
closedSlot: bigint;
|
|
104
|
+
}
|
|
105
|
+
export interface DecodedMemoPageScanSlice extends DecodedMemoPageHeader {
|
|
106
|
+
viewTags: Uint8Array[];
|
|
107
|
+
ephemeralPks: Uint8Array[];
|
|
108
|
+
hasCiphertexts: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface DecodedNullifierPageHeader {
|
|
111
|
+
laneId: number;
|
|
112
|
+
bump: number;
|
|
113
|
+
count: number;
|
|
114
|
+
poolId: number;
|
|
115
|
+
pageSeq: bigint;
|
|
116
|
+
createdSlot: bigint;
|
|
117
|
+
closedSlot: bigint;
|
|
118
|
+
}
|
|
119
|
+
export interface DecodedNullifierPage {
|
|
120
|
+
laneId: number;
|
|
121
|
+
bump: number;
|
|
122
|
+
count: number;
|
|
123
|
+
poolId: number;
|
|
124
|
+
pageSeq: bigint;
|
|
125
|
+
createdSlot: bigint;
|
|
126
|
+
closedSlot: bigint;
|
|
127
|
+
prefixes: Uint8Array[];
|
|
128
|
+
}
|
|
129
|
+
export declare function decodePoolState(data: Uint8Array): DecodedPoolState;
|
|
130
|
+
export declare function decodeLaneHeader(data: Uint8Array): DecodedLaneHeader;
|
|
131
|
+
export declare function decodeSlotRingEntry(data: Uint8Array, idx: number): RootEntry;
|
|
132
|
+
export declare function decodeEpochRingEntry(data: Uint8Array, idx: number): RootEntry;
|
|
133
|
+
export declare function decodeGlobalRootHistory(data: Uint8Array): DecodedGlobalRootHistory;
|
|
134
|
+
/**
|
|
135
|
+
* Select the best witness snapshot from `GlobalRootHistory` covering every `(laneId, leafIndex)`
|
|
136
|
+
* note to spend.
|
|
137
|
+
*
|
|
138
|
+
* Prefers the long-lived `stable` epoch snapshot (`ROOT_RING_EPOCH = 1`) whenever ALL notes are
|
|
139
|
+
* covered by `stableLaneCounts` (maximizing shared anonymity set & proving stability), and falls
|
|
140
|
+
* back to `latest` (`ROOT_RING_SLOT = 0`) when ANY note is newer than `stableLaneCounts` for
|
|
141
|
+
* instant 0-slot spendability.
|
|
142
|
+
*/
|
|
143
|
+
export declare function selectRootSnapshotForNotes(history: DecodedGlobalRootHistory, notes: ReadonlyArray<{
|
|
144
|
+
laneId: number;
|
|
145
|
+
leafIndex: bigint;
|
|
146
|
+
}>): RootSnapshotChoice | null;
|
|
147
|
+
export declare function decodeSubtreePage(data: Uint8Array): DecodedSubtreePage;
|
|
148
|
+
export declare function decodeSubtreeRootPage(data: Uint8Array): DecodedSubtreeRootPage;
|
|
149
|
+
export declare function decodeMemoPage(data: Uint8Array): DecodedMemoPage;
|
|
150
|
+
export declare function decodeMemoPageHeader(data: Uint8Array): DecodedMemoPageHeader;
|
|
151
|
+
export declare function decodeMemoPageScanSlice(data: Uint8Array): DecodedMemoPageScanSlice;
|
|
152
|
+
export declare function decodeNullifierPageHeader(data: Uint8Array): DecodedNullifierPageHeader;
|
|
153
|
+
export declare function decodeNullifierPage(data: Uint8Array): DecodedNullifierPage;
|