@utxopia/sdk 0.1.0-alpha.1

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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -0
  3. package/package.json +108 -0
  4. package/packages/btc-client/src/esplora-client.ts +153 -0
  5. package/packages/btc-client/src/index.ts +3 -0
  6. package/packages/btc-client/src/op-return.ts +93 -0
  7. package/packages/btc-client/src/types.ts +112 -0
  8. package/packages/sdk/README.md +277 -0
  9. package/packages/sdk/dist/announcement-client.d.ts +64 -0
  10. package/packages/sdk/dist/announcement-client.js +337 -0
  11. package/packages/sdk/dist/auditor-ciphertext.d.ts +72 -0
  12. package/packages/sdk/dist/auditor-ciphertext.js +135 -0
  13. package/packages/sdk/dist/auditor.d.ts +115 -0
  14. package/packages/sdk/dist/auditor.js +292 -0
  15. package/packages/sdk/dist/bitcoin/ika.d.ts +47 -0
  16. package/packages/sdk/dist/bitcoin/ika.js +74 -0
  17. package/packages/sdk/dist/bitcoin/index.d.ts +2 -0
  18. package/packages/sdk/dist/bitcoin/index.js +1 -0
  19. package/packages/sdk/dist/bound-params.d.ts +96 -0
  20. package/packages/sdk/dist/bound-params.js +249 -0
  21. package/packages/sdk/dist/chadbuffer.d.ts +124 -0
  22. package/packages/sdk/dist/chadbuffer.js +405 -0
  23. package/packages/sdk/dist/claim-link.d.ts +30 -0
  24. package/packages/sdk/dist/claim-link.js +50 -0
  25. package/packages/sdk/dist/client.d.ts +233 -0
  26. package/packages/sdk/dist/client.js +416 -0
  27. package/packages/sdk/dist/commitment-tree.d.ts +268 -0
  28. package/packages/sdk/dist/commitment-tree.js +564 -0
  29. package/packages/sdk/dist/config.d.ts +177 -0
  30. package/packages/sdk/dist/config.js +426 -0
  31. package/packages/sdk/dist/core/esplora.d.ts +110 -0
  32. package/packages/sdk/dist/core/esplora.js +187 -0
  33. package/packages/sdk/dist/core/mempool.d.ts +60 -0
  34. package/packages/sdk/dist/core/mempool.js +107 -0
  35. package/packages/sdk/dist/crypto-babyjub.d.ts +105 -0
  36. package/packages/sdk/dist/crypto-babyjub.js +312 -0
  37. package/packages/sdk/dist/crypto-ed25519.d.ts +116 -0
  38. package/packages/sdk/dist/crypto-ed25519.js +235 -0
  39. package/packages/sdk/dist/crypto.d.ts +59 -0
  40. package/packages/sdk/dist/crypto.js +140 -0
  41. package/packages/sdk/dist/event-client.d.ts +64 -0
  42. package/packages/sdk/dist/event-client.js +165 -0
  43. package/packages/sdk/dist/events.d.ts +127 -0
  44. package/packages/sdk/dist/events.js +305 -0
  45. package/packages/sdk/dist/explorer.d.ts +86 -0
  46. package/packages/sdk/dist/explorer.js +197 -0
  47. package/packages/sdk/dist/index.d.ts +61 -0
  48. package/packages/sdk/dist/index.js +216 -0
  49. package/packages/sdk/dist/instructions.d.ts +1125 -0
  50. package/packages/sdk/dist/instructions.js +1760 -0
  51. package/packages/sdk/dist/keys.d.ts +467 -0
  52. package/packages/sdk/dist/keys.js +799 -0
  53. package/packages/sdk/dist/logger.d.ts +10 -0
  54. package/packages/sdk/dist/logger.js +40 -0
  55. package/packages/sdk/dist/magicblock.d.ts +90 -0
  56. package/packages/sdk/dist/magicblock.js +164 -0
  57. package/packages/sdk/dist/merkle.d.ts +82 -0
  58. package/packages/sdk/dist/merkle.js +141 -0
  59. package/packages/sdk/dist/note.d.ts +348 -0
  60. package/packages/sdk/dist/note.js +483 -0
  61. package/packages/sdk/dist/pda.d.ts +160 -0
  62. package/packages/sdk/dist/pda.js +384 -0
  63. package/packages/sdk/dist/pool-state.d.ts +100 -0
  64. package/packages/sdk/dist/pool-state.js +126 -0
  65. package/packages/sdk/dist/poseidon.d.ts +53 -0
  66. package/packages/sdk/dist/poseidon.js +136 -0
  67. package/packages/sdk/dist/prover/index.d.ts +10 -0
  68. package/packages/sdk/dist/prover/index.js +10 -0
  69. package/packages/sdk/dist/prover/mobile.d.ts +45 -0
  70. package/packages/sdk/dist/prover/mobile.js +227 -0
  71. package/packages/sdk/dist/prover/web.d.ts +136 -0
  72. package/packages/sdk/dist/prover/web.js +597 -0
  73. package/packages/sdk/dist/psbt.d.ts +73 -0
  74. package/packages/sdk/dist/psbt.js +202 -0
  75. package/packages/sdk/dist/selective-disclosure.d.ts +181 -0
  76. package/packages/sdk/dist/selective-disclosure.js +172 -0
  77. package/packages/sdk/dist/sender-memo.d.ts +149 -0
  78. package/packages/sdk/dist/sender-memo.js +250 -0
  79. package/packages/sdk/dist/sns-resolver.d.ts +121 -0
  80. package/packages/sdk/dist/sns-resolver.js +229 -0
  81. package/packages/sdk/dist/solana/connection.d.ts +77 -0
  82. package/packages/sdk/dist/solana/connection.js +133 -0
  83. package/packages/sdk/dist/solana/priority-fee.d.ts +78 -0
  84. package/packages/sdk/dist/solana/priority-fee.js +137 -0
  85. package/packages/sdk/dist/stealth.d.ts +429 -0
  86. package/packages/sdk/dist/stealth.js +703 -0
  87. package/packages/sdk/dist/taproot.d.ts +172 -0
  88. package/packages/sdk/dist/taproot.js +494 -0
  89. package/packages/sdk/dist/token-registry.d.ts +96 -0
  90. package/packages/sdk/dist/token-registry.js +122 -0
  91. package/packages/sdk/dist/utils/encoding.d.ts +19 -0
  92. package/packages/sdk/dist/utils/encoding.js +29 -0
  93. package/packages/sdk/dist/vk-registry.d.ts +100 -0
  94. package/packages/sdk/dist/vk-registry.js +212 -0
@@ -0,0 +1,467 @@
1
+ /**
2
+ * Key Derivation for UTXOpia (Baby Jubjub + Ed25519)
3
+ *
4
+ * Dual-curve architecture (Railgun-style):
5
+ * - Baby Jubjub spending key: SNARK-friendly, in-circuit verification via BabyPbk()
6
+ * - Ed25519 viewing key: Standard fast curve, off-chain ECDH only
7
+ *
8
+ * Key Architecture:
9
+ * ```
10
+ * Solana Wallet (Ed25519)
11
+ * │
12
+ * │ signs message: "UTXOpia key derivation v1"
13
+ * ▼
14
+ * Signature (64 bytes)
15
+ * │
16
+ * ├──► SHA256(sig || "spend") mod BJJ_ORDER ──► Baby Jubjub Spending Key
17
+ * │
18
+ * └──► SHA256(sig || "view") ──► Ed25519 Viewing Key
19
+ * ```
20
+ *
21
+ * Stealth Address Flow:
22
+ * ```
23
+ * Sender:
24
+ * 1. ephemeral = random Ed25519 keypair
25
+ * 2. sharedSecret = X25519(ephemeral.priv, viewingPubX25519)
26
+ * 3. stealthScalar = SHA256(sharedSecret || domain) mod BJJ_ORDER
27
+ * 4. stealthPub = spendingPub + stealthScalar × BASE8
28
+ * 5. commitment = Poseidon(stealthPub.x, amount)
29
+ *
30
+ * Recipient (viewing key - can detect):
31
+ * 1. sharedSecret = X25519(viewingPriv, ephemeralPub)
32
+ * 2. Decrypt amount, derive stealthPub, verify commitment
33
+ *
34
+ * Recipient (spending key - can claim):
35
+ * 1. stealthPriv = spendingPriv + stealthScalar
36
+ * 2. Circuit proves: BabyPbk(stealthPriv).x == pub_key_x
37
+ * ```
38
+ */
39
+ import { type BabyJubPoint } from "./crypto";
40
+ /**
41
+ * Complete UTXOpia key hierarchy derived from Solana wallet
42
+ *
43
+ * Uses Baby Jubjub for spending keys and Ed25519 for viewing keys.
44
+ */
45
+ export interface UTXOpiaKeys {
46
+ /** Solana public key (32 bytes) - user identity */
47
+ solanaPublicKey: Uint8Array;
48
+ /** Baby Jubjub spending private key (scalar) - for stealthPriv and nullifier */
49
+ spendingPrivKey: bigint;
50
+ /** Baby Jubjub spending public key (point) - share publicly */
51
+ spendingPubKey: BabyJubPoint;
52
+ /** Nullifying key (BN254 scalar) - for JoinSplit nullifier computation */
53
+ nullifyingKey: bigint;
54
+ /** Ed25519 viewing private key (32 bytes) - for X25519 ECDH scanning */
55
+ viewingPrivKey: Uint8Array;
56
+ /** Ed25519 viewing public key (32 bytes) - share publicly */
57
+ viewingPubKey: Uint8Array;
58
+ /** Raw EdDSA seed bytes (32 bytes) - for circomlibjs EdDSA-Poseidon signing */
59
+ eddsaSeed: Uint8Array;
60
+ }
61
+ /**
62
+ * Stealth meta-address for receiving funds
63
+ *
64
+ * Total size: 96 bytes (32 BJJ compressed + 32 Ed25519 + 32 MPK)
65
+ */
66
+ export interface StealthMetaAddress {
67
+ /** Baby Jubjub spending public key (32 bytes compressed) */
68
+ spendingPubKey: Uint8Array;
69
+ /** Ed25519 viewing public key (32 bytes) */
70
+ viewingPubKey: Uint8Array;
71
+ /** Master public key (32 bytes, Poseidon hash as BE bytes) */
72
+ mpk: Uint8Array;
73
+ }
74
+ /**
75
+ * Serialized stealth meta-address for display/sharing
76
+ */
77
+ export interface SerializedStealthMetaAddress {
78
+ /** Hex-encoded spending public key */
79
+ spendingPubKey: string;
80
+ /** Hex-encoded viewing public key */
81
+ viewingPubKey: string;
82
+ /** Hex-encoded master public key (Poseidon hash) */
83
+ mpk: string;
84
+ }
85
+ export interface AuthSignatureKeyDerivationOptions {
86
+ /** Wallet address or app account label used as domain context. */
87
+ account?: string;
88
+ /** Chain label used for domain separation. */
89
+ chain?: string;
90
+ /** Network label used for domain separation. */
91
+ network?: string;
92
+ }
93
+ export interface AuthSignatureKeySetupResult {
94
+ keys: UTXOpiaKeys;
95
+ stealthMetaAddress: StealthMetaAddress;
96
+ encodedStealthAddress: string;
97
+ root: Uint8Array;
98
+ }
99
+ export declare const PASSKEY_CHAIN_SCOPE_DOMAIN = "utxopia-passkey-chain:v1";
100
+ export type PasskeyChainScope = "sol";
101
+ export interface ChainScopedPasskeyOptions {
102
+ chain: PasskeyChainScope;
103
+ network: string;
104
+ }
105
+ /**
106
+ * Scope a passkey seed to one app chain+network identity.
107
+ *
108
+ * This convention is intentionally centralized in the SDK so apps, tests, and
109
+ * dev tooling derive the same private address without duplicating string
110
+ * literals.
111
+ */
112
+ export declare function deriveChainScopedPasskeySeed(seed: Uint8Array, options: ChainScopedPasskeyOptions): Uint8Array;
113
+ export declare function passkeyStorageOwner(credentialId: string, options: ChainScopedPasskeyOptions): string;
114
+ /**
115
+ * View permission flags for delegated viewing keys
116
+ */
117
+ export declare enum ViewPermissions {
118
+ /** Can scan announcements and see amounts */
119
+ SCAN = 1,
120
+ /** Can see full transaction history */
121
+ HISTORY = 2,
122
+ /** Can see incoming transactions only */
123
+ INCOMING_ONLY = 4,
124
+ /** Full viewing access (scan + history) */
125
+ FULL = 3
126
+ }
127
+ /**
128
+ * Delegated viewing key for auditors/compliance
129
+ *
130
+ * Uses Ed25519 private key for viewing. Deposit verification additionally
131
+ * requires `spendingPubKeyCompressed` and `nullifyingKey` so the scanner
132
+ * can compute MPK; without them, only transfer-type announcements can be
133
+ * confidently matched.
134
+ */
135
+ export interface DelegatedViewKey {
136
+ /** Ed25519 viewing private key (32 bytes) */
137
+ viewingPrivKey: Uint8Array;
138
+ /** Permission flags */
139
+ permissions: ViewPermissions;
140
+ /** Baby Jubjub spending pubkey, compressed (32 bytes). Needed for deposit verification. */
141
+ spendingPubKeyCompressed?: Uint8Array;
142
+ /** Nullifying key (BN254 scalar). Needed for deposit verification. */
143
+ nullifyingKey?: bigint;
144
+ /** Inclusive lower slot bound for audit scope (honor-system on auditor side). */
145
+ fromSlot?: number;
146
+ /** Inclusive upper slot bound for audit scope. */
147
+ toSlot?: number;
148
+ /** Optional expiration timestamp (Unix ms) */
149
+ expiresAt?: number;
150
+ /** Optional label for identification */
151
+ label?: string;
152
+ /** Unix ms when the delegation was created (set by createDelegatedViewKey). */
153
+ issuedAt?: number;
154
+ /** Stable opaque ID for tracking this delegation in the user's audit trail. */
155
+ delegationId?: string;
156
+ }
157
+ /**
158
+ * Public record of a delegation that the *user* keeps as their audit trail of
159
+ * keys they have handed out — never carries the viewing private key itself.
160
+ */
161
+ export interface DelegationRecord {
162
+ delegationId: string;
163
+ fingerprint: string;
164
+ permissions: ViewPermissions;
165
+ fromSlot?: number;
166
+ toSlot?: number;
167
+ expiresAt?: number;
168
+ issuedAt: number;
169
+ label?: string;
170
+ /** Optional free-form note about who received the key (auditor name, firm, etc.). */
171
+ recipient?: string;
172
+ }
173
+ /** Message to sign for key derivation */
174
+ export declare const SPENDING_KEY_DERIVATION_MESSAGE = "UTXOpia key derivation v1";
175
+ /**
176
+ * Derive Baby Jubjub public key from raw seed using circomlibjs EdDSA.
177
+ *
178
+ * circomlibjs internally hashes the seed (like standard EdDSA key derivation),
179
+ * producing keys compatible with the EdDSAPoseidonVerifier circuit.
180
+ * This is NOT the same as `babyJubMul(scalarFromBytes(seed), BASE8)`.
181
+ */
182
+ export declare function eddsaGetPubKey(seed: Uint8Array): Promise<BabyJubPoint>;
183
+ /**
184
+ * Extract the internal EdDSA private scalar from a seed.
185
+ *
186
+ * circomlibjs does: BLAKE-512(seed) → pruneBuffer → fromRprLE(32 bytes) → shr(3)
187
+ * This scalar × BASE8 = the public key from `eddsaGetPubKey(seed)`.
188
+ *
189
+ * We intercept circomlibjs's `pruneBuffer` call during `prv2pub` to capture
190
+ * the intermediate buffer, then replicate the LE→bigint→shr(3) conversion.
191
+ * This avoids directly importing ffjavascript/blake-hash which aren't bundled by webpack.
192
+ */
193
+ export declare function eddsaGetPrivScalar(seed: Uint8Array): Promise<bigint>;
194
+ /**
195
+ * Sign a message hash with EdDSA-Poseidon (circomlibjs).
196
+ *
197
+ * Returns [R8.x, R8.y, S] compatible with the EdDSAPoseidonVerifier circuit.
198
+ */
199
+ export declare function eddsaPoseidonSign(seed: Uint8Array, msgHash: bigint): Promise<[bigint, bigint, bigint]>;
200
+ /**
201
+ * Sign a message hash with EdDSA-Poseidon using a given private scalar directly.
202
+ *
203
+ * Unlike `eddsaPoseidonSign` which derives the scalar internally via circomlibjs's
204
+ * BLAKE-512 derivation, this function uses the provided scalar as-is.
205
+ * This is needed when the public key was derived via `scalarFromBytes` (sync)
206
+ * rather than circomlibjs's internal derivation.
207
+ *
208
+ * Returns [R8.x, R8.y, S] compatible with the EdDSAPoseidonVerifier circuit.
209
+ */
210
+ export declare function eddsaPoseidonSignWithScalar(privScalar: bigint, pubKey: BabyJubPoint, msgHash: bigint): [bigint, bigint, bigint];
211
+ /**
212
+ * Minimal wallet adapter interface for signing
213
+ * Compatible with @solana/wallet-adapter-base
214
+ */
215
+ export interface WalletSignerAdapter {
216
+ publicKey: {
217
+ toBytes(): Uint8Array;
218
+ } | null;
219
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
220
+ }
221
+ /**
222
+ * Derive UTXOpia keys from Solana wallet signature.
223
+ *
224
+ * Uses circomlibjs EdDSA for spendingPubKey derivation so keys are
225
+ * compatible with the EdDSAPoseidonVerifier circuit.
226
+ */
227
+ export declare function deriveKeysFromWallet(wallet: WalletSignerAdapter): Promise<UTXOpiaKeys>;
228
+ /**
229
+ * Derive UTXOpia keys from a signature
230
+ *
231
+ * Spending key: SHA256(sig || "spend") → reduce mod BJJ_ORDER → babyJubMul(scalar, BASE8)
232
+ * Viewing key: SHA256(sig || "view") → Ed25519 private key → ed25519.getPublicKey()
233
+ */
234
+ export declare function deriveKeysFromSignature(signature: Uint8Array, solanaPublicKey: Uint8Array): UTXOpiaKeys;
235
+ /**
236
+ * Generate a random 65-byte signature-shaped seed for dev/test auth flows.
237
+ *
238
+ * Mirrors Fluidkey's "signature as deterministic key source" shape without
239
+ * requiring a wallet or zkLogin proof during local testing.
240
+ */
241
+ export declare function generateRandomAuthSignature(): Uint8Array;
242
+ /**
243
+ * Derive UTXOpia keys from a wallet/zkLogin signature-shaped secret.
244
+ *
245
+ * User-facing model is two keys:
246
+ * - spending seed/key
247
+ * - viewing seed/key
248
+ *
249
+ * The protocol nullifying key is internal and derived from the spending seed,
250
+ * so delegated viewing keys do not automatically carry nullifier authority.
251
+ */
252
+ export declare function deriveKeysFromAuthSignature(signature: Uint8Array, options?: AuthSignatureKeyDerivationOptions): Promise<UTXOpiaKeys>;
253
+ export declare function setupKeysFromAuthSignature(signature: Uint8Array, options?: AuthSignatureKeyDerivationOptions): Promise<AuthSignatureKeySetupResult>;
254
+ /**
255
+ * Derive keys from a seed phrase (sync — for scanning/non-circuit use)
256
+ */
257
+ export declare function deriveKeysFromSeed(seed: Uint8Array): UTXOpiaKeys;
258
+ /**
259
+ * Derive keys from a seed phrase with circomlibjs-compatible spending keys.
260
+ *
261
+ * Must be used when the keys will be used for circuit proofs (EdDSA signing).
262
+ * The sync `deriveKeysFromSeed` uses a different scalar derivation that doesn't
263
+ * match circomlibjs's internal BLAKE-512 derivation used by `eddsaPoseidonSign`.
264
+ */
265
+ export declare function deriveKeysFromSeedCircuit(seed: Uint8Array): Promise<UTXOpiaKeys>;
266
+ /**
267
+ * Create a stealth meta-address from UTXOpia keys
268
+ *
269
+ * Size: 96 bytes (32 BJJ compressed + 32 Ed25519 + 32 MPK)
270
+ */
271
+ export declare function createStealthMetaAddress(keys: UTXOpiaKeys): StealthMetaAddress;
272
+ /**
273
+ * Serialize a stealth meta-address for display/sharing
274
+ */
275
+ export declare function serializeStealthMetaAddress(meta: StealthMetaAddress): SerializedStealthMetaAddress;
276
+ /**
277
+ * Deserialize a stealth meta-address from string representation
278
+ */
279
+ export declare function deserializeStealthMetaAddress(serialized: SerializedStealthMetaAddress): StealthMetaAddress;
280
+ /**
281
+ * Parse a stealth meta-address and extract public keys
282
+ *
283
+ * Returns Baby Jubjub spending pubkey and Ed25519 viewing pubkey.
284
+ */
285
+ export declare function parseStealthMetaAddress(meta: StealthMetaAddress): {
286
+ spendingPubKey: BabyJubPoint;
287
+ viewingPubKey: Uint8Array;
288
+ };
289
+ /**
290
+ * Encode stealth meta-address as a single string with utxo: prefix
291
+ * Format: "utxo:" + hex(spendingPubKey (32) || viewingPubKey (32) || mpk (32))
292
+ */
293
+ export declare function encodeStealthMetaAddress(meta: StealthMetaAddress): string;
294
+ /**
295
+ * Decode stealth meta-address from a string (with or without utxo: prefix)
296
+ */
297
+ export declare function decodeStealthMetaAddress(encoded: string): StealthMetaAddress;
298
+ /**
299
+ * Create a delegated viewing key for auditors/compliance
300
+ *
301
+ * The returned key carries everything an auditor needs to scan announcements
302
+ * within the configured slot range, including the spending pubkey and
303
+ * nullifying key (required for deposit verification — `Poseidon(npk, token, amount)`
304
+ * must match on-chain commitment). A fresh `delegationId` and `issuedAt` are
305
+ * generated so the user can keep an [[auditable-disclosure-status]] trail of
306
+ * who they handed keys to.
307
+ */
308
+ export declare function createDelegatedViewKey(keys: UTXOpiaKeys, permissions?: ViewPermissions, options?: {
309
+ fromSlot?: number;
310
+ toSlot?: number;
311
+ expiresAt?: number;
312
+ label?: string;
313
+ }): DelegatedViewKey;
314
+ /**
315
+ * Build a public-only record of a delegated viewing key for the issuer's
316
+ * audit trail. Strips the secret material; only carries identifiers + scope.
317
+ */
318
+ export declare function makeDelegationRecord(key: DelegatedViewKey, options?: {
319
+ recipient?: string;
320
+ }): DelegationRecord;
321
+ /**
322
+ * Compute a stable fingerprint for a delegated viewing key.
323
+ *
324
+ * `sha256(viewingPrivKey)[..16]` rendered as hex — short enough to display,
325
+ * long enough to make collisions astronomically unlikely. Identical viewing
326
+ * keys produce identical fingerprints, so the user can detect duplicate
327
+ * delegations across export sessions.
328
+ */
329
+ export declare function fingerprintDelegatedKey(key: DelegatedViewKey): string;
330
+ /**
331
+ * Decide whether a slot falls within the delegated key's permitted range.
332
+ * No range bound on a side ⇒ unbounded on that side.
333
+ */
334
+ export declare function isSlotInDelegatedRange(key: DelegatedViewKey, slot: number | undefined): boolean;
335
+ /**
336
+ * Serialize a delegated viewing key for export (ENCRYPTED)
337
+ */
338
+ export declare function serializeDelegatedViewKey(key: DelegatedViewKey, password?: string): Promise<string>;
339
+ /**
340
+ * Deserialize a delegated viewing key from JSON.
341
+ *
342
+ * v1 keys are refused at parse time by default (they lack
343
+ * `spendingPubKeyCompressed`/`nullifyingKey`, so `auditScan` would error out
344
+ * downstream anyway — failing early gives callers a clearer message and
345
+ * avoids partial setup). Set `acceptV1: true` to opt in for migration
346
+ * tools that need to crack open old blobs to re-issue them as v2.
347
+ */
348
+ export declare function deserializeDelegatedViewKey(json: string, password?: string, options?: {
349
+ acceptV1?: boolean;
350
+ }): Promise<DelegatedViewKey>;
351
+ /**
352
+ * Check if a delegated viewing key is valid (not expired)
353
+ */
354
+ export declare function isDelegatedKeyValid(key: DelegatedViewKey): boolean;
355
+ /**
356
+ * Check if a delegated key has a specific permission
357
+ */
358
+ export declare function hasPermission(key: DelegatedViewKey, permission: ViewPermissions): boolean;
359
+ /**
360
+ * Safely compare two keys in constant time
361
+ */
362
+ export declare function constantTimeCompare(a: Uint8Array, b: Uint8Array): boolean;
363
+ /**
364
+ * Securely clear sensitive key material from memory
365
+ */
366
+ export declare function clearKey(key: Uint8Array): void;
367
+ /**
368
+ * Securely clear all sensitive keys from an UTXOpiaKeys object
369
+ */
370
+ export declare function clearUTXOpiaKeys(keys: UTXOpiaKeys): void;
371
+ /**
372
+ * Securely clear a delegated viewing key
373
+ */
374
+ export declare function clearDelegatedViewKey(key: DelegatedViewKey): void;
375
+ /**
376
+ * Derive a view-only key bundle (no spending key)
377
+ * Safe to export/backup separately from spending key
378
+ */
379
+ export declare function extractViewOnlyBundle(keys: UTXOpiaKeys): {
380
+ solanaPublicKey: Uint8Array;
381
+ spendingPubKey: Uint8Array;
382
+ viewingPrivKey: Uint8Array;
383
+ viewingPubKey: Uint8Array;
384
+ };
385
+ /**
386
+ * Serialized key storage format (all values are hex strings or string-encoded bigints).
387
+ */
388
+ export interface SerializedKeysForStorage {
389
+ eddsaSeedHex: string;
390
+ spendingPrivKeyHex: string;
391
+ spendingPubKey: {
392
+ x: string;
393
+ y: string;
394
+ };
395
+ nullifyingKey: string;
396
+ viewingPrivKeyHex: string;
397
+ viewingPubKeyHex: string;
398
+ }
399
+ /**
400
+ * Serialize UTXOpiaKeys to a plain object with hex strings (for encrypted storage).
401
+ *
402
+ * The result is JSON-safe. Use `deserializeKeysFromStorage` to reconstruct.
403
+ */
404
+ export declare function serializeKeysForStorage(keys: UTXOpiaKeys): SerializedKeysForStorage;
405
+ /**
406
+ * Deserialize UTXOpiaKeys from a storage object (reverse of serializeKeysForStorage).
407
+ *
408
+ * Requires `solanaPublicKey` to be provided separately since it is not stored
409
+ * in the serialized format (it comes from the connected wallet).
410
+ */
411
+ export declare function deserializeKeysFromStorage(data: SerializedKeysForStorage, solanaPublicKey: Uint8Array): UTXOpiaKeys;
412
+ /**
413
+ * Result of a complete key setup operation (derivation + stealth address creation).
414
+ */
415
+ export interface KeySetupResult {
416
+ keys: UTXOpiaKeys;
417
+ stealthAddress: StealthMetaAddress;
418
+ stealthAddressEncoded: string;
419
+ }
420
+ /**
421
+ * Derive keys from wallet signature and create stealth address in one step.
422
+ *
423
+ * Combines deriveKeysFromWallet + createStealthMetaAddress + encodeStealthMetaAddress.
424
+ */
425
+ export declare function setupKeysFromWallet(wallet: WalletSignerAdapter): Promise<KeySetupResult>;
426
+ /**
427
+ * Derive keys from seed (passkey PRF or secret phrase) and create stealth address in one step.
428
+ *
429
+ * Combines deriveKeysFromSeedCircuit + createStealthMetaAddress + encodeStealthMetaAddress.
430
+ */
431
+ export declare function setupKeysFromSeed(seed: Uint8Array): Promise<KeySetupResult>;
432
+ /**
433
+ * Recreate stealth address from existing keys (for hydration from storage).
434
+ *
435
+ * Use this when keys are already deserialized and you just need the stealth address.
436
+ */
437
+ export declare function recreateStealthAddress(keys: UTXOpiaKeys): {
438
+ stealthAddress: StealthMetaAddress;
439
+ stealthAddressEncoded: string;
440
+ };
441
+ /**
442
+ * Generate a random Ed25519 auditor viewing keypair.
443
+ *
444
+ * Thin wrapper over `ed25519GenerateKeyPair`. The returned keys are suitable
445
+ * for use as the auditor viewing key pair in `encryptAuditorCiphertext` /
446
+ * `decryptAuditorCiphertext`.
447
+ *
448
+ * @returns 32-byte private key and 32-byte Ed25519 public key
449
+ */
450
+ export declare function generateAuditorViewingKeypair(): {
451
+ privKey: Uint8Array;
452
+ pubKey: Uint8Array;
453
+ };
454
+ /**
455
+ * Derive a deterministic Ed25519 auditor viewing keypair from a 32-byte seed.
456
+ *
457
+ * Uses `ed25519DeriveKeyFromSeed` which SHA-256s the seed to produce the
458
+ * Ed25519 private key, then derives the matching public key. Same seed always
459
+ * yields the same keypair; different seeds yield different keypairs.
460
+ *
461
+ * @param seed - 32-byte seed (e.g. from a KDF or random source)
462
+ * @returns 32-byte private key and 32-byte Ed25519 public key
463
+ */
464
+ export declare function deriveAuditorViewingKeypair(seed: Uint8Array): {
465
+ privKey: Uint8Array;
466
+ pubKey: Uint8Array;
467
+ };