@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,158 @@
1
+ import { K as KeyDerivationConfig, M as MasterKeys, b as StarkMasterKeys, a as DualMasterKeys, A as AuditKeyExport } from '../types-CJSbxv4q.cjs';
2
+ export { D as DEFAULT_KEY_DERIVATION_CONFIG, O as OneTimeKeys, P as ProvingSystem, S as SerializedKeys, c as StealthAddressComponents, T as TransactionViewingKey } from '../types-CJSbxv4q.cjs';
3
+ import { Hex, Address } from 'viem';
4
+ import { M as M31Secret } from '../keccak-m31-B_AqBbRF.cjs';
5
+
6
+ /**
7
+ * Key Derivation from Wallet Signature (Post-Quantum / Hash-Based)
8
+ *
9
+ * Derives keys from an Ethereum wallet signature using only hash functions.
10
+ * No elliptic curve operations — quantum-resistant by design.
11
+ *
12
+ * Security Model:
13
+ * - Keys are derived deterministically from the signature
14
+ * - No seed phrase management required
15
+ * - Same signature always produces same keys
16
+ * - Ownership proven via hash preimage (Poseidon), not discrete log
17
+ */
18
+
19
+ /**
20
+ * Derive master keys from a wallet signature (hash-based, post-quantum)
21
+ *
22
+ * This replaces the previous BabyJubJub-based derivation.
23
+ * Instead of curve points, we use Poseidon hashes for ownership proofs.
24
+ *
25
+ * @param signature - The wallet signature (from personal_sign or EIP-712)
26
+ * @param config - Optional key derivation configuration
27
+ * @returns Master keys for stealth operations
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const signature = await walletClient.signMessage({
32
+ * message: 'UPP Stealth Key Derivation v1'
33
+ * })
34
+ * const keys = await deriveKeysFromSignature(signature)
35
+ * // keys.ownerHash is Poseidon(spendingSecret) — used in note commitments
36
+ * ```
37
+ */
38
+ declare function deriveKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): Promise<MasterKeys>;
39
+ /**
40
+ * Get the message to sign for key derivation
41
+ */
42
+ declare function getKeyDerivationMessage(config?: KeyDerivationConfig): string;
43
+ /**
44
+ * Verify that keys match a given signature
45
+ */
46
+ declare function verifyKeysMatchSignature(keys: MasterKeys, signature: Hex, config?: KeyDerivationConfig): Promise<boolean>;
47
+ /**
48
+ * Derive STARK master keys from a wallet signature (M31/Keccak, post-quantum)
49
+ *
50
+ * Uses domain-separated keccak256 to derive M31 secrets, then keccak_m31
51
+ * for owner/viewing hashes. No elliptic curve operations.
52
+ *
53
+ * @param signature - The wallet signature (same one used for SNARK keys)
54
+ * @param config - Optional key derivation configuration
55
+ * @returns STARK master keys for stealth operations
56
+ */
57
+ declare function deriveStarkKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): StarkMasterKeys;
58
+ /**
59
+ * Derive both SNARK and STARK keys from a single wallet signature.
60
+ *
61
+ * Same seed, domain-separated derivation. Breaking BJJ (quantum) does NOT
62
+ * compromise STARK keys — keccak preimage resistance provides 2^128 quantum security.
63
+ */
64
+ declare function deriveDualKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): Promise<DualMasterKeys>;
65
+ /**
66
+ * Derive a nullifier key from the spending secret
67
+ *
68
+ * nullifier = Poseidon(nullifierKey, leafIndex, commitment)
69
+ */
70
+ declare function deriveNullifierKey(spendingSecret: bigint): Promise<bigint>;
71
+
72
+ /**
73
+ * Per-Transaction Viewing Key Derivation (Post-Quantum, Hash-Based)
74
+ *
75
+ * Implements hierarchical viewing keys using Poseidon hash instead of ECDH.
76
+ *
77
+ * Key Properties:
78
+ * - Per-note decryption key: Poseidon(viewingSecret, nonce)
79
+ * - AES key: keccak256(perNoteKey) for symmetric encryption
80
+ *
81
+ * Derivation:
82
+ * perNoteKey = Poseidon(viewingSecret, nonce)
83
+ * aesKey = keccak256(perNoteKey)
84
+ *
85
+ * SECURITY (v4):
86
+ * Audit exports contain per-note decryption keys derived from viewingSecret + nonce.
87
+ * This prevents master key recovery: knowing Poseidon(viewingSecret, nonce) doesn't
88
+ * reveal viewingSecret due to the one-wayness of Poseidon.
89
+ */
90
+
91
+ /**
92
+ * Derive a per-note decryption key from master viewing secret and nonce
93
+ *
94
+ * @param viewingSecret - Master viewing secret
95
+ * @param nonce - Unique per-note nonce
96
+ * @returns Per-note decryption key as hex
97
+ */
98
+ declare function derivePerNoteKey(viewingSecret: bigint, nonce: bigint): Promise<Hex>;
99
+ /**
100
+ * Derive per-note key from MasterKeys convenience wrapper
101
+ */
102
+ declare function derivePerNoteKeyFromKeys(keys: MasterKeys, nonce: bigint): Promise<Hex>;
103
+ /**
104
+ * Note reference for audit export
105
+ */
106
+ interface NoteReference {
107
+ /** The Merkle leaf index (for locating the on-chain event) */
108
+ leafIndex: number;
109
+ /** The nonce used in per-note key derivation */
110
+ nonce: bigint;
111
+ }
112
+ /**
113
+ * Export viewing keys for specific notes
114
+ *
115
+ * Creates an export package that can be shared with an auditor.
116
+ * The auditor can use these keys to decrypt the specified notes,
117
+ * but cannot derive keys for other notes.
118
+ *
119
+ * @param keys - Master keys
120
+ * @param signerAddress - The Ethereum address that signed to derive keys
121
+ * @param notes - Array of note references (leafIndex + nonce) to export
122
+ * @returns Audit key export package
123
+ */
124
+ declare function exportViewingKeysForAudit(keys: MasterKeys, signerAddress: Address, notes: NoteReference[]): Promise<AuditKeyExport>;
125
+ /**
126
+ * Validate an audit key export
127
+ */
128
+ declare function validateAuditKeyExport(exportData: AuditKeyExport): {
129
+ valid: boolean;
130
+ error?: string;
131
+ };
132
+ /**
133
+ * Look up a decryption key from an audit export by leaf index
134
+ *
135
+ * Returns the per-note decryption key for direct use in AES-GCM decryption.
136
+ * Derive AES key: keccak256(decryptionKey)
137
+ */
138
+ declare function getViewingKeyFromExport(exportData: AuditKeyExport, leafIndex: number): Hex | null;
139
+ /**
140
+ * Derive a STARK per-note decryption key from viewing secret and nonce.
141
+ *
142
+ * Uses keccak_m31 instead of Poseidon — purely symmetric, post-quantum safe.
143
+ * The nonce is encoded as a single M31 element appended to the viewing secret.
144
+ *
145
+ * perNoteDigest = keccak_m31(viewingSecret[0..8], nonce)
146
+ * aesKey = keccak256(perNoteDigest_packed_as_16_LE_bytes)
147
+ *
148
+ * @param starkViewingSecret - 8 M31 limbs (the master STARK viewing secret)
149
+ * @param nonce - Per-note nonce (M31 range)
150
+ * @returns 32-byte AES key as hex
151
+ */
152
+ declare function deriveStarkPerNoteKey(starkViewingSecret: M31Secret, nonce: bigint): Hex;
153
+ /**
154
+ * Derive STARK per-note key from StarkMasterKeys convenience wrapper
155
+ */
156
+ declare function deriveStarkPerNoteKeyFromKeys(keys: StarkMasterKeys, nonce: bigint): Hex;
157
+
158
+ export { AuditKeyExport, DualMasterKeys, KeyDerivationConfig, MasterKeys, type NoteReference, StarkMasterKeys, deriveDualKeysFromSignature, deriveKeysFromSignature, deriveNullifierKey, derivePerNoteKey, derivePerNoteKeyFromKeys, deriveStarkKeysFromSignature, deriveStarkPerNoteKey, deriveStarkPerNoteKeyFromKeys, exportViewingKeysForAudit, getKeyDerivationMessage, getViewingKeyFromExport, validateAuditKeyExport, verifyKeysMatchSignature };
@@ -0,0 +1,158 @@
1
+ import { K as KeyDerivationConfig, M as MasterKeys, b as StarkMasterKeys, a as DualMasterKeys, A as AuditKeyExport } from '../types-mLybMxNR.js';
2
+ export { D as DEFAULT_KEY_DERIVATION_CONFIG, O as OneTimeKeys, P as ProvingSystem, S as SerializedKeys, c as StealthAddressComponents, T as TransactionViewingKey } from '../types-mLybMxNR.js';
3
+ import { Hex, Address } from 'viem';
4
+ import { M as M31Secret } from '../keccak-m31-B_AqBbRF.js';
5
+
6
+ /**
7
+ * Key Derivation from Wallet Signature (Post-Quantum / Hash-Based)
8
+ *
9
+ * Derives keys from an Ethereum wallet signature using only hash functions.
10
+ * No elliptic curve operations — quantum-resistant by design.
11
+ *
12
+ * Security Model:
13
+ * - Keys are derived deterministically from the signature
14
+ * - No seed phrase management required
15
+ * - Same signature always produces same keys
16
+ * - Ownership proven via hash preimage (Poseidon), not discrete log
17
+ */
18
+
19
+ /**
20
+ * Derive master keys from a wallet signature (hash-based, post-quantum)
21
+ *
22
+ * This replaces the previous BabyJubJub-based derivation.
23
+ * Instead of curve points, we use Poseidon hashes for ownership proofs.
24
+ *
25
+ * @param signature - The wallet signature (from personal_sign or EIP-712)
26
+ * @param config - Optional key derivation configuration
27
+ * @returns Master keys for stealth operations
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const signature = await walletClient.signMessage({
32
+ * message: 'UPP Stealth Key Derivation v1'
33
+ * })
34
+ * const keys = await deriveKeysFromSignature(signature)
35
+ * // keys.ownerHash is Poseidon(spendingSecret) — used in note commitments
36
+ * ```
37
+ */
38
+ declare function deriveKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): Promise<MasterKeys>;
39
+ /**
40
+ * Get the message to sign for key derivation
41
+ */
42
+ declare function getKeyDerivationMessage(config?: KeyDerivationConfig): string;
43
+ /**
44
+ * Verify that keys match a given signature
45
+ */
46
+ declare function verifyKeysMatchSignature(keys: MasterKeys, signature: Hex, config?: KeyDerivationConfig): Promise<boolean>;
47
+ /**
48
+ * Derive STARK master keys from a wallet signature (M31/Keccak, post-quantum)
49
+ *
50
+ * Uses domain-separated keccak256 to derive M31 secrets, then keccak_m31
51
+ * for owner/viewing hashes. No elliptic curve operations.
52
+ *
53
+ * @param signature - The wallet signature (same one used for SNARK keys)
54
+ * @param config - Optional key derivation configuration
55
+ * @returns STARK master keys for stealth operations
56
+ */
57
+ declare function deriveStarkKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): StarkMasterKeys;
58
+ /**
59
+ * Derive both SNARK and STARK keys from a single wallet signature.
60
+ *
61
+ * Same seed, domain-separated derivation. Breaking BJJ (quantum) does NOT
62
+ * compromise STARK keys — keccak preimage resistance provides 2^128 quantum security.
63
+ */
64
+ declare function deriveDualKeysFromSignature(signature: Hex, config?: KeyDerivationConfig): Promise<DualMasterKeys>;
65
+ /**
66
+ * Derive a nullifier key from the spending secret
67
+ *
68
+ * nullifier = Poseidon(nullifierKey, leafIndex, commitment)
69
+ */
70
+ declare function deriveNullifierKey(spendingSecret: bigint): Promise<bigint>;
71
+
72
+ /**
73
+ * Per-Transaction Viewing Key Derivation (Post-Quantum, Hash-Based)
74
+ *
75
+ * Implements hierarchical viewing keys using Poseidon hash instead of ECDH.
76
+ *
77
+ * Key Properties:
78
+ * - Per-note decryption key: Poseidon(viewingSecret, nonce)
79
+ * - AES key: keccak256(perNoteKey) for symmetric encryption
80
+ *
81
+ * Derivation:
82
+ * perNoteKey = Poseidon(viewingSecret, nonce)
83
+ * aesKey = keccak256(perNoteKey)
84
+ *
85
+ * SECURITY (v4):
86
+ * Audit exports contain per-note decryption keys derived from viewingSecret + nonce.
87
+ * This prevents master key recovery: knowing Poseidon(viewingSecret, nonce) doesn't
88
+ * reveal viewingSecret due to the one-wayness of Poseidon.
89
+ */
90
+
91
+ /**
92
+ * Derive a per-note decryption key from master viewing secret and nonce
93
+ *
94
+ * @param viewingSecret - Master viewing secret
95
+ * @param nonce - Unique per-note nonce
96
+ * @returns Per-note decryption key as hex
97
+ */
98
+ declare function derivePerNoteKey(viewingSecret: bigint, nonce: bigint): Promise<Hex>;
99
+ /**
100
+ * Derive per-note key from MasterKeys convenience wrapper
101
+ */
102
+ declare function derivePerNoteKeyFromKeys(keys: MasterKeys, nonce: bigint): Promise<Hex>;
103
+ /**
104
+ * Note reference for audit export
105
+ */
106
+ interface NoteReference {
107
+ /** The Merkle leaf index (for locating the on-chain event) */
108
+ leafIndex: number;
109
+ /** The nonce used in per-note key derivation */
110
+ nonce: bigint;
111
+ }
112
+ /**
113
+ * Export viewing keys for specific notes
114
+ *
115
+ * Creates an export package that can be shared with an auditor.
116
+ * The auditor can use these keys to decrypt the specified notes,
117
+ * but cannot derive keys for other notes.
118
+ *
119
+ * @param keys - Master keys
120
+ * @param signerAddress - The Ethereum address that signed to derive keys
121
+ * @param notes - Array of note references (leafIndex + nonce) to export
122
+ * @returns Audit key export package
123
+ */
124
+ declare function exportViewingKeysForAudit(keys: MasterKeys, signerAddress: Address, notes: NoteReference[]): Promise<AuditKeyExport>;
125
+ /**
126
+ * Validate an audit key export
127
+ */
128
+ declare function validateAuditKeyExport(exportData: AuditKeyExport): {
129
+ valid: boolean;
130
+ error?: string;
131
+ };
132
+ /**
133
+ * Look up a decryption key from an audit export by leaf index
134
+ *
135
+ * Returns the per-note decryption key for direct use in AES-GCM decryption.
136
+ * Derive AES key: keccak256(decryptionKey)
137
+ */
138
+ declare function getViewingKeyFromExport(exportData: AuditKeyExport, leafIndex: number): Hex | null;
139
+ /**
140
+ * Derive a STARK per-note decryption key from viewing secret and nonce.
141
+ *
142
+ * Uses keccak_m31 instead of Poseidon — purely symmetric, post-quantum safe.
143
+ * The nonce is encoded as a single M31 element appended to the viewing secret.
144
+ *
145
+ * perNoteDigest = keccak_m31(viewingSecret[0..8], nonce)
146
+ * aesKey = keccak256(perNoteDigest_packed_as_16_LE_bytes)
147
+ *
148
+ * @param starkViewingSecret - 8 M31 limbs (the master STARK viewing secret)
149
+ * @param nonce - Per-note nonce (M31 range)
150
+ * @returns 32-byte AES key as hex
151
+ */
152
+ declare function deriveStarkPerNoteKey(starkViewingSecret: M31Secret, nonce: bigint): Hex;
153
+ /**
154
+ * Derive STARK per-note key from StarkMasterKeys convenience wrapper
155
+ */
156
+ declare function deriveStarkPerNoteKeyFromKeys(keys: StarkMasterKeys, nonce: bigint): Hex;
157
+
158
+ export { AuditKeyExport, DualMasterKeys, KeyDerivationConfig, MasterKeys, type NoteReference, StarkMasterKeys, deriveDualKeysFromSignature, deriveKeysFromSignature, deriveNullifierKey, derivePerNoteKey, derivePerNoteKeyFromKeys, deriveStarkKeysFromSignature, deriveStarkPerNoteKey, deriveStarkPerNoteKeyFromKeys, exportViewingKeysForAudit, getKeyDerivationMessage, getViewingKeyFromExport, validateAuditKeyExport, verifyKeysMatchSignature };
@@ -0,0 +1,7 @@
1
+ export { DEFAULT_KEY_DERIVATION_CONFIG, deriveDualKeysFromSignature, deriveKeysFromSignature, deriveNullifierKey, derivePerNoteKey, derivePerNoteKeyFromKeys, deriveStarkKeysFromSignature, deriveStarkPerNoteKey, deriveStarkPerNoteKeyFromKeys, exportViewingKeysForAudit, getKeyDerivationMessage, getViewingKeyFromExport, validateAuditKeyExport, verifyKeysMatchSignature } from '../chunk-2JQISXBD.js';
2
+ import '../chunk-5V5HSN6Y.js';
3
+ import '../chunk-W77GRBO4.js';
4
+ import '../chunk-V23OSL25.js';
5
+ import '../chunk-Z6ZWNWWR.js';
6
+ //# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,5 @@
1
+ export { MAX_TREE_DEPTH, MerkleTree, buildMerkleTree, getMerkleProof, verifyMerkleProof } from './chunk-ZU6J7KMY.js';
2
+ import './chunk-V23OSL25.js';
3
+ import './chunk-Z6ZWNWWR.js';
4
+ //# sourceMappingURL=merkle-7KS2EHRF.js.map
5
+ //# sourceMappingURL=merkle-7KS2EHRF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"merkle-7KS2EHRF.js"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var chunkEUP7MBAH_cjs = require('./chunk-EUP7MBAH.cjs');
4
+ require('./chunk-JWNXBALH.cjs');
5
+ require('./chunk-G7VZBCD6.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "MAX_TREE_DEPTH", {
10
+ enumerable: true,
11
+ get: function () { return chunkEUP7MBAH_cjs.MAX_TREE_DEPTH; }
12
+ });
13
+ Object.defineProperty(exports, "MerkleTree", {
14
+ enumerable: true,
15
+ get: function () { return chunkEUP7MBAH_cjs.MerkleTree; }
16
+ });
17
+ Object.defineProperty(exports, "buildMerkleTree", {
18
+ enumerable: true,
19
+ get: function () { return chunkEUP7MBAH_cjs.buildMerkleTree; }
20
+ });
21
+ Object.defineProperty(exports, "getMerkleProof", {
22
+ enumerable: true,
23
+ get: function () { return chunkEUP7MBAH_cjs.getMerkleProof; }
24
+ });
25
+ Object.defineProperty(exports, "verifyMerkleProof", {
26
+ enumerable: true,
27
+ get: function () { return chunkEUP7MBAH_cjs.verifyMerkleProof; }
28
+ });
29
+ //# sourceMappingURL=merkle-HGDC6OB4.cjs.map
30
+ //# sourceMappingURL=merkle-HGDC6OB4.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"merkle-HGDC6OB4.cjs"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * BabyJubJub Elliptic Curve Utilities
3
+ *
4
+ * Wrapper around circomlibjs BabyJubJub implementation.
5
+ * Used for stealth addresses, key derivation, and ECDH.
6
+ *
7
+ * BabyJubJub is a twisted Edwards curve embedded in BN254's scalar field,
8
+ * making it efficient for use in zk-SNARKs.
9
+ */
10
+ /**
11
+ * A point on the BabyJubJub curve
12
+ */
13
+ interface Point {
14
+ x: bigint;
15
+ y: bigint;
16
+ }
17
+ /**
18
+ * Get the BabyJubJub subgroup order
19
+ */
20
+ declare function getSubOrder(): Promise<bigint>;
21
+ /**
22
+ * Get the generator point (Base8)
23
+ */
24
+ declare function getBasePoint(): Promise<Point>;
25
+ /**
26
+ * Check if a point is on the curve
27
+ */
28
+ declare function isOnCurve(point: Point): Promise<boolean>;
29
+ /**
30
+ * Scalar multiplication: point * scalar
31
+ *
32
+ * @param point - Point on the curve
33
+ * @param scalar - Scalar value (mod subOrder)
34
+ * @returns Resulting point
35
+ */
36
+ declare function mulPointScalar(point: Point, scalar: bigint): Promise<Point>;
37
+ /**
38
+ * Point addition: p1 + p2
39
+ */
40
+ declare function addPoints(p1: Point, p2: Point): Promise<Point>;
41
+ /**
42
+ * Generate public key from private key
43
+ * pubKey = privateKey * Base8
44
+ *
45
+ * @param privateKey - Private key scalar (must be < subOrder)
46
+ * @returns Public key point
47
+ */
48
+ declare function privateToPublic(privateKey: bigint): Promise<Point>;
49
+ /**
50
+ * Compute ECDH shared secret
51
+ * sharedSecret = myPrivateKey * theirPublicKey
52
+ *
53
+ * @param myPrivateKey - Your private key
54
+ * @param theirPublicKey - Their public key
55
+ * @returns Shared secret point
56
+ */
57
+ declare function computeSharedSecret(myPrivateKey: bigint, theirPublicKey: Point): Promise<Point>;
58
+ /**
59
+ * Pack a point into a single bigint (compressed form)
60
+ * Uses the x-coordinate and a sign bit for y
61
+ */
62
+ declare function packPoint(point: Point): bigint;
63
+ /**
64
+ * Convert a point to tuple format [x, y] for use with snarkjs
65
+ */
66
+ declare function pointToTuple(point: Point): [bigint, bigint];
67
+ /**
68
+ * Convert a tuple [x, y] to Point format
69
+ */
70
+ declare function tupleToPoint(tuple: [bigint, bigint]): Point;
71
+ /**
72
+ * Derive a per-transaction viewing public key (EVK)
73
+ *
74
+ * EVK = MVK_pub + Poseidon(MVK_pub.x, MVK_pub.y, nonce) * Base8
75
+ *
76
+ * This allows the sender to derive a unique encryption key for each transaction
77
+ * without knowing the recipient's private key.
78
+ *
79
+ * @param masterViewingPubKey - Recipient's master viewing public key
80
+ * @param nonce - Unique per-note nonce (R.x — ephemeral public key x-coordinate)
81
+ * @returns Per-transaction encryption viewing key
82
+ */
83
+ declare function deriveEncryptionViewingKey(masterViewingPubKey: Point, nonce: bigint): Promise<Point>;
84
+ /**
85
+ * Derive a per-transaction viewing private key (DVK)
86
+ *
87
+ * DVK = MVK_priv + Poseidon(MVK_pub.x, MVK_pub.y, nonce)
88
+ *
89
+ * Only the owner with MVK_priv can compute this.
90
+ * DVK can be shared with auditors to decrypt specific transactions.
91
+ *
92
+ * @param masterViewingPrivKey - Owner's master viewing private key
93
+ * @param masterViewingPubKey - Owner's master viewing public key
94
+ * @param nonce - Unique per-note nonce (R.x — ephemeral public key x-coordinate)
95
+ * @returns Per-transaction decryption viewing key
96
+ */
97
+ declare function deriveDecryptionViewingKey(masterViewingPrivKey: bigint, masterViewingPubKey: Point, nonce: bigint): Promise<bigint>;
98
+
99
+ /**
100
+ * Merkle Tree Utilities
101
+ *
102
+ * Client-side Merkle tree for computing proofs.
103
+ * Compatible with LeanIMT on-chain implementation.
104
+ */
105
+ /**
106
+ * Maximum tree depth (matches contract)
107
+ */
108
+ declare const MAX_TREE_DEPTH = 32;
109
+ /**
110
+ * Merkle proof for a leaf
111
+ */
112
+ interface MerkleProof {
113
+ /** Path elements (siblings) */
114
+ pathElements: bigint[];
115
+ /** Path indices (0 = left, 1 = right) */
116
+ pathIndices: number[];
117
+ /** Leaf index in the tree */
118
+ leafIndex: number;
119
+ /** Tree root */
120
+ root: bigint;
121
+ }
122
+ /**
123
+ * LeanIMT-compatible Merkle Tree
124
+ *
125
+ * Features:
126
+ * - Dynamic depth (grows as needed)
127
+ * - Single-child optimization
128
+ * - Async hash operations (Poseidon is async)
129
+ */
130
+ declare class MerkleTree {
131
+ private leaves;
132
+ private nodes;
133
+ private cachedRoot;
134
+ readonly maxDepth: number;
135
+ constructor(maxDepth?: number);
136
+ /**
137
+ * Insert a leaf into the tree
138
+ */
139
+ insert(leaf: bigint): number;
140
+ /**
141
+ * Get the number of leaves in the tree
142
+ */
143
+ get size(): number;
144
+ /**
145
+ * Get the current depth of the tree
146
+ * LeanIMT: depth grows when 2^depth < size
147
+ */
148
+ get depth(): number;
149
+ /**
150
+ * Check if a leaf exists in the tree
151
+ */
152
+ has(leaf: bigint): boolean;
153
+ /**
154
+ * Get the index of a leaf
155
+ */
156
+ indexOf(leaf: bigint): number;
157
+ /**
158
+ * Get the current root (async because of Poseidon)
159
+ */
160
+ getRoot(): Promise<bigint>;
161
+ /**
162
+ * Get a Merkle proof for a leaf at index
163
+ */
164
+ getProof(index: number): Promise<MerkleProof>;
165
+ /**
166
+ * Get the hash of a node at (level, index)
167
+ * level 0 = leaves, higher levels are internal nodes
168
+ */
169
+ private getNodeHash;
170
+ /**
171
+ * Compute the root hash
172
+ */
173
+ private computeRoot;
174
+ }
175
+ /**
176
+ * Build a Merkle tree from an array of leaves
177
+ */
178
+ declare function buildMerkleTree(leaves: bigint[]): MerkleTree;
179
+ /**
180
+ * Get a Merkle proof for a specific leaf (async)
181
+ */
182
+ declare function getMerkleProof(leaves: bigint[], index: number): Promise<MerkleProof>;
183
+ /**
184
+ * Verify a Merkle proof (async)
185
+ */
186
+ declare function verifyMerkleProof(leaf: bigint, proof: MerkleProof): Promise<boolean>;
187
+
188
+ export { MAX_TREE_DEPTH as M, type Point as P, type MerkleProof as a, MerkleTree as b, addPoints as c, buildMerkleTree as d, computeSharedSecret as e, deriveDecryptionViewingKey as f, deriveEncryptionViewingKey as g, getBasePoint as h, getMerkleProof as i, getSubOrder as j, isOnCurve as k, pointToTuple as l, mulPointScalar as m, privateToPublic as n, packPoint as p, tupleToPoint as t, verifyMerkleProof as v };