@permissionless-technologies/upp-sdk 0.1.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.
Files changed (140) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +194 -0
  3. package/dist/asp-TXSAFFD3.cjs +53 -0
  4. package/dist/asp-TXSAFFD3.cjs.map +1 -0
  5. package/dist/asp-ZA3RGN7G.js +4 -0
  6. package/dist/asp-ZA3RGN7G.js.map +1 -0
  7. package/dist/babyjubjub-2MGQVCKB.js +5 -0
  8. package/dist/babyjubjub-2MGQVCKB.js.map +1 -0
  9. package/dist/babyjubjub-MWZLJOVZ.cjs +66 -0
  10. package/dist/babyjubjub-MWZLJOVZ.cjs.map +1 -0
  11. package/dist/chunk-2JQISXBD.js +150 -0
  12. package/dist/chunk-2JQISXBD.js.map +1 -0
  13. package/dist/chunk-3HQ7A6ZM.cjs +61 -0
  14. package/dist/chunk-3HQ7A6ZM.cjs.map +1 -0
  15. package/dist/chunk-5AKBSMEQ.cjs +1008 -0
  16. package/dist/chunk-5AKBSMEQ.cjs.map +1 -0
  17. package/dist/chunk-5V5HSN6Y.js +81 -0
  18. package/dist/chunk-5V5HSN6Y.js.map +1 -0
  19. package/dist/chunk-BH24DZ5S.cjs +91 -0
  20. package/dist/chunk-BH24DZ5S.cjs.map +1 -0
  21. package/dist/chunk-C7QQOJ7T.cjs +67 -0
  22. package/dist/chunk-C7QQOJ7T.cjs.map +1 -0
  23. package/dist/chunk-ERQE57IA.cjs +404 -0
  24. package/dist/chunk-ERQE57IA.cjs.map +1 -0
  25. package/dist/chunk-EUP7MBAH.cjs +165 -0
  26. package/dist/chunk-EUP7MBAH.cjs.map +1 -0
  27. package/dist/chunk-G7VZBCD6.cjs +35 -0
  28. package/dist/chunk-G7VZBCD6.cjs.map +1 -0
  29. package/dist/chunk-GQV47S3N.cjs +10 -0
  30. package/dist/chunk-GQV47S3N.cjs.map +1 -0
  31. package/dist/chunk-GXZ3MTCQ.cjs +527 -0
  32. package/dist/chunk-GXZ3MTCQ.cjs.map +1 -0
  33. package/dist/chunk-JWNXBALH.cjs +57 -0
  34. package/dist/chunk-JWNXBALH.cjs.map +1 -0
  35. package/dist/chunk-KIKBPJXJ.cjs +348 -0
  36. package/dist/chunk-KIKBPJXJ.cjs.map +1 -0
  37. package/dist/chunk-NCW4AE7L.js +8 -0
  38. package/dist/chunk-NCW4AE7L.js.map +1 -0
  39. package/dist/chunk-NDM5EJEV.cjs +70 -0
  40. package/dist/chunk-NDM5EJEV.cjs.map +1 -0
  41. package/dist/chunk-NUIQHTSA.js +489 -0
  42. package/dist/chunk-NUIQHTSA.js.map +1 -0
  43. package/dist/chunk-OQDSHMXU.js +1002 -0
  44. package/dist/chunk-OQDSHMXU.js.map +1 -0
  45. package/dist/chunk-P37MRZ73.js +58 -0
  46. package/dist/chunk-P37MRZ73.js.map +1 -0
  47. package/dist/chunk-PWHOUQOZ.js +335 -0
  48. package/dist/chunk-PWHOUQOZ.js.map +1 -0
  49. package/dist/chunk-S4B7GYLN.js +112 -0
  50. package/dist/chunk-S4B7GYLN.js.map +1 -0
  51. package/dist/chunk-SGZZL5AC.js +59 -0
  52. package/dist/chunk-SGZZL5AC.js.map +1 -0
  53. package/dist/chunk-SQKBT2SH.cjs +122 -0
  54. package/dist/chunk-SQKBT2SH.cjs.map +1 -0
  55. package/dist/chunk-TSF6HEVS.cjs +201 -0
  56. package/dist/chunk-TSF6HEVS.cjs.map +1 -0
  57. package/dist/chunk-V23OSL25.js +48 -0
  58. package/dist/chunk-V23OSL25.js.map +1 -0
  59. package/dist/chunk-W77GRBO4.js +53 -0
  60. package/dist/chunk-W77GRBO4.js.map +1 -0
  61. package/dist/chunk-XV72HNHN.js +399 -0
  62. package/dist/chunk-XV72HNHN.js.map +1 -0
  63. package/dist/chunk-YOWDERVC.js +186 -0
  64. package/dist/chunk-YOWDERVC.js.map +1 -0
  65. package/dist/chunk-Z6ZWNWWR.js +30 -0
  66. package/dist/chunk-Z6ZWNWWR.js.map +1 -0
  67. package/dist/chunk-ZKZV6OI3.cjs +165 -0
  68. package/dist/chunk-ZKZV6OI3.cjs.map +1 -0
  69. package/dist/chunk-ZU6J7KMY.js +159 -0
  70. package/dist/chunk-ZU6J7KMY.js.map +1 -0
  71. package/dist/core/index.cjs +300 -0
  72. package/dist/core/index.cjs.map +1 -0
  73. package/dist/core/index.d.cts +9 -0
  74. package/dist/core/index.d.ts +9 -0
  75. package/dist/core/index.js +11 -0
  76. package/dist/core/index.js.map +1 -0
  77. package/dist/index-BBzvvrhG.d.ts +757 -0
  78. package/dist/index-BGvapsJy.d.cts +2811 -0
  79. package/dist/index-C-jSNw6j.d.cts +757 -0
  80. package/dist/index-ChGaGPzP.d.ts +2811 -0
  81. package/dist/index.cjs +3652 -0
  82. package/dist/index.cjs.map +1 -0
  83. package/dist/index.d.cts +12 -0
  84. package/dist/index.d.ts +12 -0
  85. package/dist/index.js +3112 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/indexer/index.cjs +58 -0
  88. package/dist/indexer/index.cjs.map +1 -0
  89. package/dist/indexer/index.d.cts +206 -0
  90. package/dist/indexer/index.d.ts +206 -0
  91. package/dist/indexer/index.js +5 -0
  92. package/dist/indexer/index.js.map +1 -0
  93. package/dist/keccak-m31-B_AqBbRF.d.cts +70 -0
  94. package/dist/keccak-m31-B_AqBbRF.d.ts +70 -0
  95. package/dist/keys/index.cjs +68 -0
  96. package/dist/keys/index.cjs.map +1 -0
  97. package/dist/keys/index.d.cts +158 -0
  98. package/dist/keys/index.d.ts +158 -0
  99. package/dist/keys/index.js +7 -0
  100. package/dist/keys/index.js.map +1 -0
  101. package/dist/merkle-7KS2EHRF.js +5 -0
  102. package/dist/merkle-7KS2EHRF.js.map +1 -0
  103. package/dist/merkle-HGDC6OB4.cjs +30 -0
  104. package/dist/merkle-HGDC6OB4.cjs.map +1 -0
  105. package/dist/merkle-mteVOlDf.d.cts +188 -0
  106. package/dist/merkle-mteVOlDf.d.ts +188 -0
  107. package/dist/poseidon-UHTJLWQM.js +7 -0
  108. package/dist/poseidon-UHTJLWQM.js.map +1 -0
  109. package/dist/poseidon-WHJSZSNP.cjs +45 -0
  110. package/dist/poseidon-WHJSZSNP.cjs.map +1 -0
  111. package/dist/proof-5OECB3RQ.cjs +45 -0
  112. package/dist/proof-5OECB3RQ.cjs.map +1 -0
  113. package/dist/proof-C4YBP6RY.js +4 -0
  114. package/dist/proof-C4YBP6RY.js.map +1 -0
  115. package/dist/react/index.cjs +2641 -0
  116. package/dist/react/index.cjs.map +1 -0
  117. package/dist/react/index.d.cts +757 -0
  118. package/dist/react/index.d.ts +757 -0
  119. package/dist/react/index.js +2598 -0
  120. package/dist/react/index.js.map +1 -0
  121. package/dist/transfer-2UDHDS7Q.cjs +37 -0
  122. package/dist/transfer-2UDHDS7Q.cjs.map +1 -0
  123. package/dist/transfer-BlmbO-Rd.d.ts +1270 -0
  124. package/dist/transfer-DKZuJnRM.d.cts +1270 -0
  125. package/dist/transfer-KTCXKHS4.js +8 -0
  126. package/dist/transfer-KTCXKHS4.js.map +1 -0
  127. package/dist/types-CJSbxv4q.d.cts +143 -0
  128. package/dist/types-mLybMxNR.d.ts +143 -0
  129. package/dist/utils/index.cjs +178 -0
  130. package/dist/utils/index.cjs.map +1 -0
  131. package/dist/utils/index.d.cts +88 -0
  132. package/dist/utils/index.d.ts +88 -0
  133. package/dist/utils/index.js +9 -0
  134. package/dist/utils/index.js.map +1 -0
  135. package/package.json +119 -0
  136. package/src/contracts/interfaces/IASPRegistry.sol +36 -0
  137. package/src/contracts/interfaces/IUniversalPrivatePool.sol +260 -0
  138. package/src/contracts/interfaces/IVerifiers.sol +68 -0
  139. package/src/deployments/11155111.json +19 -0
  140. package/src/deployments/31337.json +19 -0
@@ -0,0 +1,206 @@
1
+ import { S as StorageAdapter } from '../index-C-jSNw6j.cjs';
2
+ export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-C-jSNw6j.cjs';
3
+ import { _ as ___index_js } from '../index-BGvapsJy.cjs';
4
+ export { m as makeRpcIndexer } from '../index-BGvapsJy.cjs';
5
+ import { Hex } from 'viem';
6
+ import { P as Point } from '../merkle-mteVOlDf.cjs';
7
+ import '../transfer-DKZuJnRM.cjs';
8
+ import '../keccak-m31-B_AqBbRF.cjs';
9
+ import '@permissionless-technologies/upc-sdk';
10
+ import 'react/jsx-runtime';
11
+ import 'react';
12
+ import '../types-CJSbxv4q.cjs';
13
+ import '../keys/index.cjs';
14
+ import '../utils/index.cjs';
15
+
16
+ interface DecryptedNote {
17
+ amount: bigint;
18
+ blinding: bigint;
19
+ oneTimeSecret: bigint;
20
+ oneTimePubkey: Point;
21
+ origin: bigint;
22
+ token: bigint;
23
+ }
24
+ interface UnpackedNoteData {
25
+ searchTag: bigint;
26
+ ephemeralPubkeyX: bigint;
27
+ ephemeralPubkeyY: bigint;
28
+ encryptedNote: Hex;
29
+ }
30
+ interface DecryptionKeys {
31
+ spendingSecret: bigint;
32
+ spendingPubkey: Point;
33
+ masterViewingSecret: bigint;
34
+ masterViewingPubKey: Point;
35
+ }
36
+ type SDK = typeof ___index_js;
37
+ /**
38
+ * Compute the expected search tag for a given ephemeral public key
39
+ *
40
+ * The search tag is computed as: Poseidon(viewingSharedSecret.x, 0) & ((1n << 64n) - 1n)
41
+ * This must match how search tags are computed during note creation in createUPPNote().
42
+ *
43
+ * - DVK is the derived viewing key (derived from master viewing key using R.x as nonce)
44
+ * - R is the ephemeral public key
45
+ * - viewingSharedSecret = DVK * R
46
+ *
47
+ * This allows quick filtering of events before expensive trial decryption.
48
+ */
49
+ declare function computeSearchTag(sdk: SDK, masterViewingSecret: bigint, masterViewingPubKey: Point, ephemeralPubkey: Point, debug?: boolean): Promise<bigint>;
50
+ /**
51
+ * Check if a search tag from an event matches our viewing key
52
+ *
53
+ * This is a fast check that can filter out 99%+ of events before
54
+ * attempting expensive trial decryption.
55
+ *
56
+ * @param eventSearchTag - The search tag from the event (8 bytes as bigint)
57
+ * @param sdk - The loaded SDK module
58
+ * @param masterViewingSecret - Our master viewing secret
59
+ * @param masterViewingPubKey - Our master viewing public key
60
+ * @param ephemeralPubkey - The ephemeral public key from the event
61
+ * @param debug - Enable debug logging
62
+ * @returns true if the search tag matches (event might be ours)
63
+ */
64
+ declare function matchesSearchTag(eventSearchTag: bigint, sdk: SDK, masterViewingSecret: bigint, masterViewingPubKey: Point, ephemeralPubkey: Point, debug?: boolean): Promise<boolean>;
65
+ /**
66
+ * Try to decrypt a note using dual ECDH (UPP format with origin and token)
67
+ *
68
+ * 1. Viewing ECDH: DVK * R → AES decryption key (viewing shared secret)
69
+ * 2. Spending ECDH: spendingSecret * R → one-time key for commitment verification
70
+ *
71
+ * DVK is derived using R.x (ephemeral public key x-coordinate) as the nonce.
72
+ *
73
+ * UPP encrypted payload: amount (32) + blinding (32) + origin (20) + token (20) = 104 bytes
74
+ * UPP commitment: Poseidon(amount, pubkeyX, pubkeyY, blinding, origin, token)
75
+ *
76
+ * @param sdk - The loaded SDK module
77
+ * @param keys - Decryption keys (spending and viewing)
78
+ * @param ephemeralPubkey - The ephemeral public key from the event
79
+ * @param encryptedNote - The encrypted note data
80
+ * @param expectedCommitment - The commitment to verify against
81
+ * @param debug - Enable debug logging
82
+ * @returns Decrypted note data or null if decryption/verification failed
83
+ */
84
+ declare function tryDecryptNote(sdk: SDK, keys: DecryptionKeys, ephemeralPubkey: Point, encryptedNote: Hex, expectedCommitment: bigint, debug?: boolean): Promise<DecryptedNote | null>;
85
+ /**
86
+ * Unpack note data from packed on-chain format
87
+ *
88
+ * Format: searchTag (8 bytes) + ephemeralPubkeyX (32 bytes) + ephemeralPubkeyY (32 bytes) + encryptedNote (variable)
89
+ *
90
+ * @param packed - The packed note data from the event
91
+ * @param debug - Enable debug logging
92
+ * @returns Unpacked note data or null if format is invalid
93
+ */
94
+ declare function unpackNoteData(packed: Hex, debug?: boolean): UnpackedNoteData | null;
95
+
96
+ /**
97
+ * IndexedDB Storage Adapter
98
+ *
99
+ * Provides persistent storage using IndexedDB for browser environments.
100
+ * This is the default and recommended storage adapter for production use.
101
+ *
102
+ * Benefits:
103
+ * - Large capacity (no 5MB limit like localStorage)
104
+ * - Async API (non-blocking)
105
+ * - Supports storing large objects like Merkle trees
106
+ * - Transactional (data integrity)
107
+ */
108
+
109
+ /**
110
+ * Create an IndexedDB storage adapter
111
+ *
112
+ * @param prefix - Optional prefix for keys (useful for multi-account)
113
+ * @returns StorageAdapter instance
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const storage = createIndexedDBAdapter('account_0x123')
118
+ * await storage.set('notes', myNotes)
119
+ * const notes = await storage.get('notes')
120
+ * ```
121
+ */
122
+ declare function createIndexedDBAdapter(prefix?: string): StorageAdapter;
123
+ /**
124
+ * Default IndexedDB adapter instance (no prefix)
125
+ */
126
+ declare const indexedDBAdapter: StorageAdapter;
127
+
128
+ /**
129
+ * localStorage Storage Adapter
130
+ *
131
+ * Provides persistent storage using localStorage for browser environments.
132
+ * This is a fallback adapter when IndexedDB is not available or for simpler use cases.
133
+ *
134
+ * Limitations:
135
+ * - 5MB storage limit per origin
136
+ * - Synchronous API (blocks main thread on large operations)
137
+ * - Data must be JSON serializable
138
+ */
139
+
140
+ /**
141
+ * Create a localStorage storage adapter
142
+ *
143
+ * @param prefix - Optional prefix for keys (useful for multi-account)
144
+ * @returns StorageAdapter instance
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const storage = createLocalStorageAdapter('account_0x123')
149
+ * await storage.set('notes', myNotes)
150
+ * const notes = await storage.get('notes')
151
+ * ```
152
+ */
153
+ declare function createLocalStorageAdapter(prefix?: string): StorageAdapter;
154
+ /**
155
+ * Default localStorage adapter instance (no prefix)
156
+ */
157
+ declare const localStorageAdapter: StorageAdapter;
158
+
159
+ /**
160
+ * In-Memory Storage Adapter
161
+ *
162
+ * Provides non-persistent storage for testing and development.
163
+ * Data is lost when the process ends or the adapter is cleared.
164
+ *
165
+ * Use cases:
166
+ * - Unit tests
167
+ * - Server-side rendering (where IndexedDB/localStorage aren't available)
168
+ * - Development without persistence
169
+ */
170
+
171
+ /**
172
+ * Create an in-memory storage adapter
173
+ *
174
+ * @param prefix - Optional prefix for keys
175
+ * @returns StorageAdapter instance
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const storage = createMemoryAdapter()
180
+ * await storage.set('notes', myNotes)
181
+ * const notes = await storage.get('notes')
182
+ * ```
183
+ */
184
+ declare function createMemoryAdapter(prefix?: string): StorageAdapter & {
185
+ size(): number;
186
+ keys(): string[];
187
+ };
188
+ /**
189
+ * Default in-memory adapter instance (no prefix)
190
+ */
191
+ declare const memoryAdapter: StorageAdapter & {
192
+ size(): number;
193
+ keys(): string[];
194
+ };
195
+
196
+ /**
197
+ * Create the best available storage adapter
198
+ *
199
+ * Tries IndexedDB first, falls back to localStorage, then memory.
200
+ *
201
+ * @param prefix - Optional prefix for keys
202
+ * @returns The best available StorageAdapter
203
+ */
204
+ declare function createAutoAdapter(prefix?: string): StorageAdapter;
205
+
206
+ export { type DecryptedNote, type DecryptionKeys, StorageAdapter, type UnpackedNoteData, computeSearchTag, createAutoAdapter, createIndexedDBAdapter, createLocalStorageAdapter, createMemoryAdapter, indexedDBAdapter, localStorageAdapter, matchesSearchTag, memoryAdapter, tryDecryptNote, unpackNoteData };
@@ -0,0 +1,206 @@
1
+ import { S as StorageAdapter } from '../index-BBzvvrhG.js';
2
+ export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-BBzvvrhG.js';
3
+ import { _ as ___index_js } from '../index-ChGaGPzP.js';
4
+ export { m as makeRpcIndexer } from '../index-ChGaGPzP.js';
5
+ import { Hex } from 'viem';
6
+ import { P as Point } from '../merkle-mteVOlDf.js';
7
+ import '../transfer-BlmbO-Rd.js';
8
+ import '../keccak-m31-B_AqBbRF.js';
9
+ import '@permissionless-technologies/upc-sdk';
10
+ import 'react/jsx-runtime';
11
+ import 'react';
12
+ import '../types-mLybMxNR.js';
13
+ import '../keys/index.js';
14
+ import '../utils/index.js';
15
+
16
+ interface DecryptedNote {
17
+ amount: bigint;
18
+ blinding: bigint;
19
+ oneTimeSecret: bigint;
20
+ oneTimePubkey: Point;
21
+ origin: bigint;
22
+ token: bigint;
23
+ }
24
+ interface UnpackedNoteData {
25
+ searchTag: bigint;
26
+ ephemeralPubkeyX: bigint;
27
+ ephemeralPubkeyY: bigint;
28
+ encryptedNote: Hex;
29
+ }
30
+ interface DecryptionKeys {
31
+ spendingSecret: bigint;
32
+ spendingPubkey: Point;
33
+ masterViewingSecret: bigint;
34
+ masterViewingPubKey: Point;
35
+ }
36
+ type SDK = typeof ___index_js;
37
+ /**
38
+ * Compute the expected search tag for a given ephemeral public key
39
+ *
40
+ * The search tag is computed as: Poseidon(viewingSharedSecret.x, 0) & ((1n << 64n) - 1n)
41
+ * This must match how search tags are computed during note creation in createUPPNote().
42
+ *
43
+ * - DVK is the derived viewing key (derived from master viewing key using R.x as nonce)
44
+ * - R is the ephemeral public key
45
+ * - viewingSharedSecret = DVK * R
46
+ *
47
+ * This allows quick filtering of events before expensive trial decryption.
48
+ */
49
+ declare function computeSearchTag(sdk: SDK, masterViewingSecret: bigint, masterViewingPubKey: Point, ephemeralPubkey: Point, debug?: boolean): Promise<bigint>;
50
+ /**
51
+ * Check if a search tag from an event matches our viewing key
52
+ *
53
+ * This is a fast check that can filter out 99%+ of events before
54
+ * attempting expensive trial decryption.
55
+ *
56
+ * @param eventSearchTag - The search tag from the event (8 bytes as bigint)
57
+ * @param sdk - The loaded SDK module
58
+ * @param masterViewingSecret - Our master viewing secret
59
+ * @param masterViewingPubKey - Our master viewing public key
60
+ * @param ephemeralPubkey - The ephemeral public key from the event
61
+ * @param debug - Enable debug logging
62
+ * @returns true if the search tag matches (event might be ours)
63
+ */
64
+ declare function matchesSearchTag(eventSearchTag: bigint, sdk: SDK, masterViewingSecret: bigint, masterViewingPubKey: Point, ephemeralPubkey: Point, debug?: boolean): Promise<boolean>;
65
+ /**
66
+ * Try to decrypt a note using dual ECDH (UPP format with origin and token)
67
+ *
68
+ * 1. Viewing ECDH: DVK * R → AES decryption key (viewing shared secret)
69
+ * 2. Spending ECDH: spendingSecret * R → one-time key for commitment verification
70
+ *
71
+ * DVK is derived using R.x (ephemeral public key x-coordinate) as the nonce.
72
+ *
73
+ * UPP encrypted payload: amount (32) + blinding (32) + origin (20) + token (20) = 104 bytes
74
+ * UPP commitment: Poseidon(amount, pubkeyX, pubkeyY, blinding, origin, token)
75
+ *
76
+ * @param sdk - The loaded SDK module
77
+ * @param keys - Decryption keys (spending and viewing)
78
+ * @param ephemeralPubkey - The ephemeral public key from the event
79
+ * @param encryptedNote - The encrypted note data
80
+ * @param expectedCommitment - The commitment to verify against
81
+ * @param debug - Enable debug logging
82
+ * @returns Decrypted note data or null if decryption/verification failed
83
+ */
84
+ declare function tryDecryptNote(sdk: SDK, keys: DecryptionKeys, ephemeralPubkey: Point, encryptedNote: Hex, expectedCommitment: bigint, debug?: boolean): Promise<DecryptedNote | null>;
85
+ /**
86
+ * Unpack note data from packed on-chain format
87
+ *
88
+ * Format: searchTag (8 bytes) + ephemeralPubkeyX (32 bytes) + ephemeralPubkeyY (32 bytes) + encryptedNote (variable)
89
+ *
90
+ * @param packed - The packed note data from the event
91
+ * @param debug - Enable debug logging
92
+ * @returns Unpacked note data or null if format is invalid
93
+ */
94
+ declare function unpackNoteData(packed: Hex, debug?: boolean): UnpackedNoteData | null;
95
+
96
+ /**
97
+ * IndexedDB Storage Adapter
98
+ *
99
+ * Provides persistent storage using IndexedDB for browser environments.
100
+ * This is the default and recommended storage adapter for production use.
101
+ *
102
+ * Benefits:
103
+ * - Large capacity (no 5MB limit like localStorage)
104
+ * - Async API (non-blocking)
105
+ * - Supports storing large objects like Merkle trees
106
+ * - Transactional (data integrity)
107
+ */
108
+
109
+ /**
110
+ * Create an IndexedDB storage adapter
111
+ *
112
+ * @param prefix - Optional prefix for keys (useful for multi-account)
113
+ * @returns StorageAdapter instance
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const storage = createIndexedDBAdapter('account_0x123')
118
+ * await storage.set('notes', myNotes)
119
+ * const notes = await storage.get('notes')
120
+ * ```
121
+ */
122
+ declare function createIndexedDBAdapter(prefix?: string): StorageAdapter;
123
+ /**
124
+ * Default IndexedDB adapter instance (no prefix)
125
+ */
126
+ declare const indexedDBAdapter: StorageAdapter;
127
+
128
+ /**
129
+ * localStorage Storage Adapter
130
+ *
131
+ * Provides persistent storage using localStorage for browser environments.
132
+ * This is a fallback adapter when IndexedDB is not available or for simpler use cases.
133
+ *
134
+ * Limitations:
135
+ * - 5MB storage limit per origin
136
+ * - Synchronous API (blocks main thread on large operations)
137
+ * - Data must be JSON serializable
138
+ */
139
+
140
+ /**
141
+ * Create a localStorage storage adapter
142
+ *
143
+ * @param prefix - Optional prefix for keys (useful for multi-account)
144
+ * @returns StorageAdapter instance
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const storage = createLocalStorageAdapter('account_0x123')
149
+ * await storage.set('notes', myNotes)
150
+ * const notes = await storage.get('notes')
151
+ * ```
152
+ */
153
+ declare function createLocalStorageAdapter(prefix?: string): StorageAdapter;
154
+ /**
155
+ * Default localStorage adapter instance (no prefix)
156
+ */
157
+ declare const localStorageAdapter: StorageAdapter;
158
+
159
+ /**
160
+ * In-Memory Storage Adapter
161
+ *
162
+ * Provides non-persistent storage for testing and development.
163
+ * Data is lost when the process ends or the adapter is cleared.
164
+ *
165
+ * Use cases:
166
+ * - Unit tests
167
+ * - Server-side rendering (where IndexedDB/localStorage aren't available)
168
+ * - Development without persistence
169
+ */
170
+
171
+ /**
172
+ * Create an in-memory storage adapter
173
+ *
174
+ * @param prefix - Optional prefix for keys
175
+ * @returns StorageAdapter instance
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const storage = createMemoryAdapter()
180
+ * await storage.set('notes', myNotes)
181
+ * const notes = await storage.get('notes')
182
+ * ```
183
+ */
184
+ declare function createMemoryAdapter(prefix?: string): StorageAdapter & {
185
+ size(): number;
186
+ keys(): string[];
187
+ };
188
+ /**
189
+ * Default in-memory adapter instance (no prefix)
190
+ */
191
+ declare const memoryAdapter: StorageAdapter & {
192
+ size(): number;
193
+ keys(): string[];
194
+ };
195
+
196
+ /**
197
+ * Create the best available storage adapter
198
+ *
199
+ * Tries IndexedDB first, falls back to localStorage, then memory.
200
+ *
201
+ * @param prefix - Optional prefix for keys
202
+ * @returns The best available StorageAdapter
203
+ */
204
+ declare function createAutoAdapter(prefix?: string): StorageAdapter;
205
+
206
+ export { type DecryptedNote, type DecryptionKeys, StorageAdapter, type UnpackedNoteData, computeSearchTag, createAutoAdapter, createIndexedDBAdapter, createLocalStorageAdapter, createMemoryAdapter, indexedDBAdapter, localStorageAdapter, matchesSearchTag, memoryAdapter, tryDecryptNote, unpackNoteData };
@@ -0,0 +1,5 @@
1
+ export { computeSearchTag, makeRpcIndexer, matchesSearchTag, tryDecryptNote, unpackNoteData } from '../chunk-OQDSHMXU.js';
2
+ export { createAutoAdapter, createIndexedDBAdapter, createLocalStorageAdapter, createMemoryAdapter, indexedDBAdapter, localStorageAdapter, memoryAdapter } from '../chunk-XV72HNHN.js';
3
+ import '../chunk-Z6ZWNWWR.js';
4
+ //# sourceMappingURL=index.js.map
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Keccak-256 hashing over M31 field elements.
3
+ *
4
+ * This module implements the same hashing algorithm as the Rust Stwo prover
5
+ * (stwo-prover/src/hash.rs), producing identical outputs for identical inputs.
6
+ *
7
+ * Algorithm:
8
+ * 1. Each M31 element is encoded as 4 little-endian bytes
9
+ * 2. All encoded bytes are concatenated and fed to Keccak-256
10
+ * 3. The 32-byte output is split into 4 chunks of 8 bytes
11
+ * 4. Each chunk is read as a little-endian uint64 and reduced mod M31_P
12
+ *
13
+ * M31 field: p = 2^31 - 1 = 2,147,483,647
14
+ */
15
+ /** The M31 prime: 2^31 - 1 */
16
+ declare const M31_P = 2147483647n;
17
+ /** Number of M31 elements in a digest */
18
+ declare const DIGEST_SIZE = 4;
19
+ /** Number of M31 limbs for owner secrets (248 bits of entropy) */
20
+ declare const SECRET_LIMBS = 8;
21
+ /** M31 digest type: tuple of 4 M31 values */
22
+ type M31Digest = readonly [bigint, bigint, bigint, bigint];
23
+ /** M31 secret type: tuple of 8 M31 values */
24
+ type M31Secret = readonly [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];
25
+ /**
26
+ * Hash arbitrary M31 elements using Keccak-256.
27
+ *
28
+ * Matches Rust: `hash_m31(inputs: &[M31]) -> [M31; 4]`
29
+ *
30
+ * Each M31 is encoded as 4 little-endian bytes. The keccak output
31
+ * is split into 4 × 8-byte LE chunks, each reduced mod M31_P.
32
+ */
33
+ declare function keccakM31(inputs: readonly bigint[]): M31Digest;
34
+ /**
35
+ * Hash two M31 elements (Merkle tree node hash).
36
+ *
37
+ * Matches Rust: `hash_two(left: M31, right: M31) -> [M31; 4]`
38
+ */
39
+ declare function keccakHashTwo(left: bigint, right: bigint): M31Digest;
40
+ /**
41
+ * Compute owner hash from an 8-limb secret.
42
+ *
43
+ * Matches Rust: `compute_owner_hash(owner_secret: &[M31; 8]) -> [M31; 4]`
44
+ */
45
+ declare function computeStarkOwnerHash(ownerSecret: M31Secret): M31Digest;
46
+ /**
47
+ * Compute a STARK note commitment.
48
+ *
49
+ * Matches Rust: `compute_commitment(amount, owner_hash, blinding, origin, token)`
50
+ *
51
+ * Input order: [amount, ownerHash[0], ownerHash[1], ownerHash[2], ownerHash[3], blinding, origin, token]
52
+ */
53
+ declare function computeStarkCommitment(amount: bigint, ownerHash: M31Digest, blinding: bigint, origin: bigint, token: bigint): M31Digest;
54
+ /**
55
+ * Compute a STARK nullifier.
56
+ *
57
+ * Matches Rust: `compute_nullifier(owner_secret, leaf_index, commitment)`
58
+ *
59
+ * Input order: [ownerSecret[0..8], leafIndex, commitment[0..4]]
60
+ */
61
+ declare function computeStarkNullifier(ownerSecret: M31Secret, leafIndex: bigint, commitment: M31Digest): M31Digest;
62
+ /**
63
+ * Split a 32-byte keccak hash into 8 M31 limbs.
64
+ *
65
+ * Used for deriving STARK spending/viewing secrets from a seed.
66
+ * Each limb is 4 bytes of the hash, read as LE uint32, reduced mod M31_P.
67
+ */
68
+ declare function splitToM31Limbs(hashHex: `0x${string}`): M31Secret;
69
+
70
+ export { DIGEST_SIZE as D, type M31Secret as M, SECRET_LIMBS as S, type M31Digest as a, M31_P as b, computeStarkCommitment as c, computeStarkNullifier as d, computeStarkOwnerHash as e, keccakM31 as f, keccakHashTwo as k, splitToM31Limbs as s };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Keccak-256 hashing over M31 field elements.
3
+ *
4
+ * This module implements the same hashing algorithm as the Rust Stwo prover
5
+ * (stwo-prover/src/hash.rs), producing identical outputs for identical inputs.
6
+ *
7
+ * Algorithm:
8
+ * 1. Each M31 element is encoded as 4 little-endian bytes
9
+ * 2. All encoded bytes are concatenated and fed to Keccak-256
10
+ * 3. The 32-byte output is split into 4 chunks of 8 bytes
11
+ * 4. Each chunk is read as a little-endian uint64 and reduced mod M31_P
12
+ *
13
+ * M31 field: p = 2^31 - 1 = 2,147,483,647
14
+ */
15
+ /** The M31 prime: 2^31 - 1 */
16
+ declare const M31_P = 2147483647n;
17
+ /** Number of M31 elements in a digest */
18
+ declare const DIGEST_SIZE = 4;
19
+ /** Number of M31 limbs for owner secrets (248 bits of entropy) */
20
+ declare const SECRET_LIMBS = 8;
21
+ /** M31 digest type: tuple of 4 M31 values */
22
+ type M31Digest = readonly [bigint, bigint, bigint, bigint];
23
+ /** M31 secret type: tuple of 8 M31 values */
24
+ type M31Secret = readonly [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];
25
+ /**
26
+ * Hash arbitrary M31 elements using Keccak-256.
27
+ *
28
+ * Matches Rust: `hash_m31(inputs: &[M31]) -> [M31; 4]`
29
+ *
30
+ * Each M31 is encoded as 4 little-endian bytes. The keccak output
31
+ * is split into 4 × 8-byte LE chunks, each reduced mod M31_P.
32
+ */
33
+ declare function keccakM31(inputs: readonly bigint[]): M31Digest;
34
+ /**
35
+ * Hash two M31 elements (Merkle tree node hash).
36
+ *
37
+ * Matches Rust: `hash_two(left: M31, right: M31) -> [M31; 4]`
38
+ */
39
+ declare function keccakHashTwo(left: bigint, right: bigint): M31Digest;
40
+ /**
41
+ * Compute owner hash from an 8-limb secret.
42
+ *
43
+ * Matches Rust: `compute_owner_hash(owner_secret: &[M31; 8]) -> [M31; 4]`
44
+ */
45
+ declare function computeStarkOwnerHash(ownerSecret: M31Secret): M31Digest;
46
+ /**
47
+ * Compute a STARK note commitment.
48
+ *
49
+ * Matches Rust: `compute_commitment(amount, owner_hash, blinding, origin, token)`
50
+ *
51
+ * Input order: [amount, ownerHash[0], ownerHash[1], ownerHash[2], ownerHash[3], blinding, origin, token]
52
+ */
53
+ declare function computeStarkCommitment(amount: bigint, ownerHash: M31Digest, blinding: bigint, origin: bigint, token: bigint): M31Digest;
54
+ /**
55
+ * Compute a STARK nullifier.
56
+ *
57
+ * Matches Rust: `compute_nullifier(owner_secret, leaf_index, commitment)`
58
+ *
59
+ * Input order: [ownerSecret[0..8], leafIndex, commitment[0..4]]
60
+ */
61
+ declare function computeStarkNullifier(ownerSecret: M31Secret, leafIndex: bigint, commitment: M31Digest): M31Digest;
62
+ /**
63
+ * Split a 32-byte keccak hash into 8 M31 limbs.
64
+ *
65
+ * Used for deriving STARK spending/viewing secrets from a seed.
66
+ * Each limb is 4 bytes of the hash, read as LE uint32, reduced mod M31_P.
67
+ */
68
+ declare function splitToM31Limbs(hashHex: `0x${string}`): M31Secret;
69
+
70
+ export { DIGEST_SIZE as D, type M31Secret as M, SECRET_LIMBS as S, type M31Digest as a, M31_P as b, computeStarkCommitment as c, computeStarkNullifier as d, computeStarkOwnerHash as e, keccakM31 as f, keccakHashTwo as k, splitToM31Limbs as s };
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var chunkZKZV6OI3_cjs = require('../chunk-ZKZV6OI3.cjs');
4
+ require('../chunk-BH24DZ5S.cjs');
5
+ require('../chunk-3HQ7A6ZM.cjs');
6
+ require('../chunk-JWNXBALH.cjs');
7
+ require('../chunk-G7VZBCD6.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "DEFAULT_KEY_DERIVATION_CONFIG", {
12
+ enumerable: true,
13
+ get: function () { return chunkZKZV6OI3_cjs.DEFAULT_KEY_DERIVATION_CONFIG; }
14
+ });
15
+ Object.defineProperty(exports, "deriveDualKeysFromSignature", {
16
+ enumerable: true,
17
+ get: function () { return chunkZKZV6OI3_cjs.deriveDualKeysFromSignature; }
18
+ });
19
+ Object.defineProperty(exports, "deriveKeysFromSignature", {
20
+ enumerable: true,
21
+ get: function () { return chunkZKZV6OI3_cjs.deriveKeysFromSignature; }
22
+ });
23
+ Object.defineProperty(exports, "deriveNullifierKey", {
24
+ enumerable: true,
25
+ get: function () { return chunkZKZV6OI3_cjs.deriveNullifierKey; }
26
+ });
27
+ Object.defineProperty(exports, "derivePerNoteKey", {
28
+ enumerable: true,
29
+ get: function () { return chunkZKZV6OI3_cjs.derivePerNoteKey; }
30
+ });
31
+ Object.defineProperty(exports, "derivePerNoteKeyFromKeys", {
32
+ enumerable: true,
33
+ get: function () { return chunkZKZV6OI3_cjs.derivePerNoteKeyFromKeys; }
34
+ });
35
+ Object.defineProperty(exports, "deriveStarkKeysFromSignature", {
36
+ enumerable: true,
37
+ get: function () { return chunkZKZV6OI3_cjs.deriveStarkKeysFromSignature; }
38
+ });
39
+ Object.defineProperty(exports, "deriveStarkPerNoteKey", {
40
+ enumerable: true,
41
+ get: function () { return chunkZKZV6OI3_cjs.deriveStarkPerNoteKey; }
42
+ });
43
+ Object.defineProperty(exports, "deriveStarkPerNoteKeyFromKeys", {
44
+ enumerable: true,
45
+ get: function () { return chunkZKZV6OI3_cjs.deriveStarkPerNoteKeyFromKeys; }
46
+ });
47
+ Object.defineProperty(exports, "exportViewingKeysForAudit", {
48
+ enumerable: true,
49
+ get: function () { return chunkZKZV6OI3_cjs.exportViewingKeysForAudit; }
50
+ });
51
+ Object.defineProperty(exports, "getKeyDerivationMessage", {
52
+ enumerable: true,
53
+ get: function () { return chunkZKZV6OI3_cjs.getKeyDerivationMessage; }
54
+ });
55
+ Object.defineProperty(exports, "getViewingKeyFromExport", {
56
+ enumerable: true,
57
+ get: function () { return chunkZKZV6OI3_cjs.getViewingKeyFromExport; }
58
+ });
59
+ Object.defineProperty(exports, "validateAuditKeyExport", {
60
+ enumerable: true,
61
+ get: function () { return chunkZKZV6OI3_cjs.validateAuditKeyExport; }
62
+ });
63
+ Object.defineProperty(exports, "verifyKeysMatchSignature", {
64
+ enumerable: true,
65
+ get: function () { return chunkZKZV6OI3_cjs.verifyKeysMatchSignature; }
66
+ });
67
+ //# sourceMappingURL=index.cjs.map
68
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}