w3pk 0.10.4 → 0.11.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 (63) hide show
  1. package/README.md +47 -95
  2. package/dist/chainlist/index.d.mts +2 -2
  3. package/dist/chainlist/index.d.ts +2 -2
  4. package/dist/chainlist/index.js.map +1 -1
  5. package/dist/chainlist/index.mjs.map +1 -1
  6. package/dist/index.d.mts +940 -892
  7. package/dist/index.d.ts +940 -892
  8. package/dist/index.js +1135 -470
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +1135 -470
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/zk/index.d.mts +177 -4
  13. package/dist/zk/index.d.ts +177 -4
  14. package/dist/zk/index.js +5 -5
  15. package/dist/zk/index.js.map +1 -1
  16. package/dist/zk/index.mjs +5 -5
  17. package/dist/zk/index.mjs.map +1 -1
  18. package/dist/zk/prove-worker.mjs.map +1 -0
  19. package/dist/zk/utils.js +3 -3
  20. package/dist/zk/utils.js.map +1 -1
  21. package/dist/zk/utils.mjs +3 -3
  22. package/dist/zk/utils.mjs.map +1 -1
  23. package/docs/API_REFERENCE.md +517 -843
  24. package/docs/ARCHITECTURE.md +86 -106
  25. package/docs/BROWSER_COMPATIBILITY.md +15 -2
  26. package/docs/BUILD_VERIFICATION.md +35 -8
  27. package/docs/EIP-7951.md +1 -8
  28. package/docs/EIP_7702.md +35 -395
  29. package/docs/INTEGRATION_GUIDELINES.md +69 -818
  30. package/docs/JUNE_9_2026_AUDIT.md +207 -0
  31. package/docs/PORTABILITY.md +41 -186
  32. package/docs/POST_QUANTUM.md +61 -39
  33. package/docs/RECOVERY.md +165 -173
  34. package/docs/SECURITY.md +301 -891
  35. package/docs/ZK.md +250 -0
  36. package/package.json +32 -54
  37. package/dist/chainlist/index.js +0 -2
  38. package/dist/chainlist/index.mjs +0 -2
  39. package/dist/inspect/browser.d.mts +0 -106
  40. package/dist/inspect/browser.d.ts +0 -106
  41. package/dist/inspect/browser.js +0 -194
  42. package/dist/inspect/browser.js.map +0 -1
  43. package/dist/inspect/browser.mjs +0 -173
  44. package/dist/inspect/browser.mjs.map +0 -1
  45. package/dist/inspect/index.d.mts +0 -1
  46. package/dist/inspect/index.d.ts +0 -1
  47. package/dist/inspect/index.js +0 -196
  48. package/dist/inspect/index.js.map +0 -1
  49. package/dist/inspect/index.mjs +0 -173
  50. package/dist/inspect/index.mjs.map +0 -1
  51. package/dist/inspect/node.d.mts +0 -112
  52. package/dist/inspect/node.d.ts +0 -112
  53. package/dist/inspect/node.js +0 -287
  54. package/dist/inspect/node.js.map +0 -1
  55. package/dist/inspect/node.mjs +0 -251
  56. package/dist/inspect/node.mjs.map +0 -1
  57. package/docs/notes/IFRAME_IMPLEMENTATION_PLAN.md +0 -197
  58. package/docs/notes/JULY_13_ROADMAP.md +0 -29
  59. package/docs/notes/NOTES.md +0 -333
  60. package/docs/notes/SIWE_IMPLEMENTATION.md +0 -129
  61. package/docs/notes/SYNCING_ACROSS_DEVICES.md +0 -127
  62. package/docs/notes/ethereum-post-quantum-roadmap.md +0 -213
  63. package/docs/notes/wulong-building-finding.md +0 -109
@@ -16,7 +16,7 @@ type ProofType = "membership" | "threshold" | "range" | "equality" | "ownership"
16
16
  interface CircuitArtifacts {
17
17
  wasmPath: string;
18
18
  zkeyPath: string;
19
- verificationKey: any;
19
+ verificationKey: unknown;
20
20
  }
21
21
  interface ZKProof {
22
22
  type: ProofType;
@@ -33,7 +33,7 @@ interface ZKProof {
33
33
  interface VerificationResult {
34
34
  valid: boolean;
35
35
  type: ProofType;
36
- publicSignals: Record<string, any>;
36
+ publicSignals: Record<string, string>;
37
37
  timestamp: string;
38
38
  }
39
39
  /**
@@ -86,6 +86,179 @@ interface NFTOwnershipProofInput {
86
86
  minBalance?: bigint;
87
87
  }
88
88
 
89
+ /**
90
+ * Baby Jubjub (EIP-2494) point arithmetic and keys
91
+ * Matches circomlib's babyjub gadgets and circomlibjs's encodings
92
+ */
93
+ /** Affine point `[x, y]`, the layout circom signals use */
94
+ type BabyJubPoint = readonly [bigint, bigint];
95
+ interface BabyJubKeyPair {
96
+ /** Scalar in `[1, BABYJUB_SUBORDER)` */
97
+ privateKey: bigint;
98
+ /** `privateKey · BABYJUB_BASE8` */
99
+ publicKey: BabyJubPoint;
100
+ }
101
+ /** Base field: the BN254 scalar field */
102
+ declare const BABYJUB_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
103
+ declare const BABYJUB_A = 168700n;
104
+ declare const BABYJUB_D = 168696n;
105
+ /** Curve order, `8 · BABYJUB_SUBORDER` */
106
+ declare const BABYJUB_ORDER = 21888242871839275222246405745257275088614511777268538073601725287587578984328n;
107
+ /** Prime order `l` of the subgroup generated by `BABYJUB_BASE8` */
108
+ declare const BABYJUB_SUBORDER: bigint;
109
+ declare const BABYJUB_GENERATOR: BabyJubPoint;
110
+ /** `8 · BABYJUB_GENERATOR`, the base point of circomlib's `BabyPbk` and `EscalarMulFix` */
111
+ declare const BABYJUB_BASE8: BabyJubPoint;
112
+ declare const BABYJUB_IDENTITY: BabyJubPoint;
113
+ /**
114
+ * Check that `p` has canonical coordinates in `[0, p)` and lies on the curve
115
+ */
116
+ declare function isOnBabyJub(p: BabyJubPoint): boolean;
117
+ /**
118
+ * Check that `p` lies on the curve and in the prime-order subgroup,
119
+ * which rejects the small-order (torsion) points
120
+ */
121
+ declare function isInBabyJubSubgroup(p: BabyJubPoint): boolean;
122
+ declare function babyJubAdd(p: BabyJubPoint, q: BabyJubPoint): BabyJubPoint;
123
+ declare function babyJubNeg(p: BabyJubPoint): BabyJubPoint;
124
+ /**
125
+ * Scalar multiplication `e · p` by a Montgomery ladder over at least 256
126
+ * bits, so the work doesn't depend on the scalar's bits. The scalar is
127
+ * not reduced, so `babyJubMul(p, BABYJUB_SUBORDER)` exposes torsion components
128
+ */
129
+ declare function babyJubMul(p: BabyJubPoint, e: bigint): BabyJubPoint;
130
+ declare function babyJubEquals(p: BabyJubPoint, q: BabyJubPoint): boolean;
131
+ /**
132
+ * Pack a point into 32 bytes as circomlibjs's `packPoint` does:
133
+ * `y` little-endian, with the top bit set when `x > (p - 1) / 2`
134
+ */
135
+ declare function packBabyJubPoint(p: BabyJubPoint): Uint8Array;
136
+ /**
137
+ * Unpack 32 bytes from `packBabyJubPoint`. Rejects non-canonical `y`,
138
+ * encodings with no point on the curve, and a sign bit on `x = 0`.
139
+ * Does not check the subgroup: use `unpackBabyJubPublicKey` for keys
140
+ */
141
+ declare function unpackBabyJubPoint(bytes: Uint8Array): BabyJubPoint;
142
+ /**
143
+ * A public key must be in the prime-order subgroup and not the identity
144
+ */
145
+ declare function isValidBabyJubPublicKey(p: BabyJubPoint): boolean;
146
+ declare function assertBabyJubPublicKey(p: BabyJubPoint): void;
147
+ declare function assertBabyJubPrivateKey(privateKey: bigint): void;
148
+ declare function packBabyJubPublicKey(publicKey: BabyJubPoint): Uint8Array;
149
+ declare function unpackBabyJubPublicKey(bytes: Uint8Array): BabyJubPoint;
150
+ /**
151
+ * Uniform scalar in `[1, BABYJUB_SUBORDER)`, from 64 random bytes
152
+ */
153
+ declare function randomBabyJubScalar(): bigint;
154
+ /**
155
+ * Public key `privateKey · BABYJUB_BASE8`, as circomlib's `BabyPbk` computes it
156
+ */
157
+ declare function babyJubPublicKey(privateKey: bigint): BabyJubPoint;
158
+ declare function generateBabyJubKeyPair(): BabyJubKeyPair;
159
+ /**
160
+ * Derive a key pair from a secret of at least 16 bytes, such as
161
+ * `derivePrfSecret()`'s output. The scalar is
162
+ * `HKDF-SHA256(secret, info = "w3pk-babyjub-v1", 64 bytes) mod (l - 1) + 1`
163
+ */
164
+ declare function deriveBabyJubKeyPair(secret: Uint8Array): BabyJubKeyPair;
165
+ /**
166
+ * Smallest `m` in `[0, maxValue]` with `m · BABYJUB_BASE8 = point`, by
167
+ * baby-step giant-step, or `null` when there is none. `maxValue` is at
168
+ * most 2^32, which takes about 2^17 point additions
169
+ */
170
+ declare function babyJubDiscreteLog(point: BabyJubPoint, maxValue: number): bigint | null;
171
+
172
+ /**
173
+ * Exponential ElGamal over Baby Jubjub
174
+ * Enc(m; r) = (r · B, m · B + r · PK), with B = BABYJUB_BASE8
175
+ */
176
+
177
+ interface ElGamalCiphertext {
178
+ /** `r · B` */
179
+ c1: BabyJubPoint;
180
+ /** `m · B + r · PK` */
181
+ c2: BabyJubPoint;
182
+ }
183
+ /**
184
+ * Encrypt `message` in `[0, l)` to `publicKey`. `r` defaults to a fresh
185
+ * random scalar; pass it when a proof needs it as a witness
186
+ */
187
+ declare function elgamalEncrypt(publicKey: BabyJubPoint, message: bigint, r?: bigint): ElGamalCiphertext;
188
+ /**
189
+ * Ciphertext of `m1 + m2` under the same key, with randomness `r1 + r2`
190
+ */
191
+ declare function elgamalAdd(a: ElGamalCiphertext, b: ElGamalCiphertext): ElGamalCiphertext;
192
+ /**
193
+ * Same plaintext under fresh randomness: adds an encryption of 0 with `r`
194
+ */
195
+ declare function elgamalRerandomize(publicKey: BabyJubPoint, ciphertext: ElGamalCiphertext, r?: bigint): ElGamalCiphertext;
196
+ /**
197
+ * Recover `m · B = c2 - privateKey · c1`
198
+ */
199
+ declare function elgamalDecryptToPoint(privateKey: bigint, ciphertext: ElGamalCiphertext): BabyJubPoint;
200
+ /**
201
+ * Decrypt a message known to be in `[0, maxValue]`, such as a tally.
202
+ * Throws when the plaintext is out of range
203
+ */
204
+ declare function elgamalDecrypt(privateKey: bigint, ciphertext: ElGamalCiphertext, maxValue: number): bigint;
205
+
206
+ /**
207
+ * Custom error classes for better error handling
208
+ */
209
+ declare class Web3PasskeyError extends Error {
210
+ code: string;
211
+ originalError?: unknown | undefined;
212
+ constructor(message: string, code: string, originalError?: unknown | undefined);
213
+ }
214
+ type ZkArtifactName = "wasm" | "zkey";
215
+ /**
216
+ * A circuit artifact's IPFS CID doesn't match the CID pinned onchain,
217
+ * so it isn't the circuit the app chose.
218
+ */
219
+ declare class ZkArtifactMismatchError extends Web3PasskeyError {
220
+ artifact: ZkArtifactName;
221
+ expectedCid: string;
222
+ actualCid: string;
223
+ constructor(artifact: ZkArtifactName, expectedCid: string, actualCid: string);
224
+ }
225
+
226
+ /**
227
+ * Circuit artifact verification against CIDs pinned onchain
228
+ */
229
+
230
+ /** Artifact bytes, or a URL to fetch them from */
231
+ type ZkArtifactSource = ArrayBufferView | ArrayBuffer | string;
232
+ type ZkArtifactSources = Record<ZkArtifactName, ZkArtifactSource>;
233
+ /**
234
+ * IPFS CIDv1 strings in base32, as `ipfs add --cid-version 1` prints them,
235
+ * compared as exact strings
236
+ */
237
+ type ZkArtifactPins = Record<ZkArtifactName, string>;
238
+ type ZkArtifactBytes = Record<ZkArtifactName, Uint8Array>;
239
+ /**
240
+ * Any contract with the build registry's `getCidByVersion(string)`,
241
+ * such as an ethers `Contract`
242
+ */
243
+ interface ZkArtifactRegistry {
244
+ getCidByVersion(key: string): Promise<string>;
245
+ }
246
+ /**
247
+ * Reads the pinned CIDs of a circuit's artifacts from a registry with the
248
+ * build registry's interface, under the given keys
249
+ *
250
+ * @throws Web3PasskeyError `ZK_ARTIFACT_NOT_PINNED` if a key has no CID
251
+ */
252
+ declare function readZkArtifactPins(registry: ZkArtifactRegistry, keys: Record<ZkArtifactName, string>): Promise<ZkArtifactPins>;
253
+ /**
254
+ * Computes the IPFS CIDs of a circuit's `.wasm` and `.zkey` and checks them
255
+ * against the pinned CIDs. Prove with the returned bytes, not by fetching
256
+ * the URLs again, so the checked artifacts are the ones used.
257
+ *
258
+ * @throws ZkArtifactMismatchError if an artifact's CID differs from its pin
259
+ */
260
+ declare function verifyZkArtifacts(artifacts: ZkArtifactSources, pins: ZkArtifactPins): Promise<ZkArtifactBytes>;
261
+
89
262
  /**
90
263
  * Zero-Knowledge Proof Module for w3pk SDK
91
264
  * Enables privacy-preserving proofs
@@ -151,7 +324,7 @@ declare class ZKProofModule {
151
324
  */
152
325
  verifyNFTOwnership(proof: ZKProof, expectedContract: string, expectedHoldersRoot: string, expectedMinBalance?: bigint): Promise<boolean>;
153
326
  /**
154
- * Create a Pedersen commitment for hiding values
327
+ * Create a Poseidon commitment for hiding values
155
328
  */
156
329
  createCommitment(value: bigint, blinding: bigint): Promise<string>;
157
330
  /**
@@ -172,4 +345,4 @@ declare class ZKProofModule {
172
345
  get isAvailable(): boolean;
173
346
  }
174
347
 
175
- export { type CircuitArtifacts, type MembershipProofInput, type NFTOwnershipProofInput, type OwnershipProofInput, type ProofType, type RangeProofInput, type ThresholdProofInput, type VerificationResult, type ZKProof, type ZKProofConfig, ZKProofModule };
348
+ export { BABYJUB_A, BABYJUB_BASE8, BABYJUB_D, BABYJUB_FIELD, BABYJUB_GENERATOR, BABYJUB_IDENTITY, BABYJUB_ORDER, BABYJUB_SUBORDER, type BabyJubKeyPair, type BabyJubPoint, type CircuitArtifacts, type ElGamalCiphertext, type MembershipProofInput, type NFTOwnershipProofInput, type OwnershipProofInput, type ProofType, type RangeProofInput, type ThresholdProofInput, type VerificationResult, type ZKProof, type ZKProofConfig, ZKProofModule, type ZkArtifactBytes, ZkArtifactMismatchError, type ZkArtifactName, type ZkArtifactPins, type ZkArtifactRegistry, type ZkArtifactSource, type ZkArtifactSources, assertBabyJubPrivateKey, assertBabyJubPublicKey, babyJubAdd, babyJubDiscreteLog, babyJubEquals, babyJubMul, babyJubNeg, babyJubPublicKey, deriveBabyJubKeyPair, elgamalAdd, elgamalDecrypt, elgamalDecryptToPoint, elgamalEncrypt, elgamalRerandomize, generateBabyJubKeyPair, isInBabyJubSubgroup, isOnBabyJub, isValidBabyJubPublicKey, packBabyJubPoint, packBabyJubPublicKey, randomBabyJubScalar, readZkArtifactPins, unpackBabyJubPoint, unpackBabyJubPublicKey, verifyZkArtifacts };
@@ -16,7 +16,7 @@ type ProofType = "membership" | "threshold" | "range" | "equality" | "ownership"
16
16
  interface CircuitArtifacts {
17
17
  wasmPath: string;
18
18
  zkeyPath: string;
19
- verificationKey: any;
19
+ verificationKey: unknown;
20
20
  }
21
21
  interface ZKProof {
22
22
  type: ProofType;
@@ -33,7 +33,7 @@ interface ZKProof {
33
33
  interface VerificationResult {
34
34
  valid: boolean;
35
35
  type: ProofType;
36
- publicSignals: Record<string, any>;
36
+ publicSignals: Record<string, string>;
37
37
  timestamp: string;
38
38
  }
39
39
  /**
@@ -86,6 +86,179 @@ interface NFTOwnershipProofInput {
86
86
  minBalance?: bigint;
87
87
  }
88
88
 
89
+ /**
90
+ * Baby Jubjub (EIP-2494) point arithmetic and keys
91
+ * Matches circomlib's babyjub gadgets and circomlibjs's encodings
92
+ */
93
+ /** Affine point `[x, y]`, the layout circom signals use */
94
+ type BabyJubPoint = readonly [bigint, bigint];
95
+ interface BabyJubKeyPair {
96
+ /** Scalar in `[1, BABYJUB_SUBORDER)` */
97
+ privateKey: bigint;
98
+ /** `privateKey · BABYJUB_BASE8` */
99
+ publicKey: BabyJubPoint;
100
+ }
101
+ /** Base field: the BN254 scalar field */
102
+ declare const BABYJUB_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
103
+ declare const BABYJUB_A = 168700n;
104
+ declare const BABYJUB_D = 168696n;
105
+ /** Curve order, `8 · BABYJUB_SUBORDER` */
106
+ declare const BABYJUB_ORDER = 21888242871839275222246405745257275088614511777268538073601725287587578984328n;
107
+ /** Prime order `l` of the subgroup generated by `BABYJUB_BASE8` */
108
+ declare const BABYJUB_SUBORDER: bigint;
109
+ declare const BABYJUB_GENERATOR: BabyJubPoint;
110
+ /** `8 · BABYJUB_GENERATOR`, the base point of circomlib's `BabyPbk` and `EscalarMulFix` */
111
+ declare const BABYJUB_BASE8: BabyJubPoint;
112
+ declare const BABYJUB_IDENTITY: BabyJubPoint;
113
+ /**
114
+ * Check that `p` has canonical coordinates in `[0, p)` and lies on the curve
115
+ */
116
+ declare function isOnBabyJub(p: BabyJubPoint): boolean;
117
+ /**
118
+ * Check that `p` lies on the curve and in the prime-order subgroup,
119
+ * which rejects the small-order (torsion) points
120
+ */
121
+ declare function isInBabyJubSubgroup(p: BabyJubPoint): boolean;
122
+ declare function babyJubAdd(p: BabyJubPoint, q: BabyJubPoint): BabyJubPoint;
123
+ declare function babyJubNeg(p: BabyJubPoint): BabyJubPoint;
124
+ /**
125
+ * Scalar multiplication `e · p` by a Montgomery ladder over at least 256
126
+ * bits, so the work doesn't depend on the scalar's bits. The scalar is
127
+ * not reduced, so `babyJubMul(p, BABYJUB_SUBORDER)` exposes torsion components
128
+ */
129
+ declare function babyJubMul(p: BabyJubPoint, e: bigint): BabyJubPoint;
130
+ declare function babyJubEquals(p: BabyJubPoint, q: BabyJubPoint): boolean;
131
+ /**
132
+ * Pack a point into 32 bytes as circomlibjs's `packPoint` does:
133
+ * `y` little-endian, with the top bit set when `x > (p - 1) / 2`
134
+ */
135
+ declare function packBabyJubPoint(p: BabyJubPoint): Uint8Array;
136
+ /**
137
+ * Unpack 32 bytes from `packBabyJubPoint`. Rejects non-canonical `y`,
138
+ * encodings with no point on the curve, and a sign bit on `x = 0`.
139
+ * Does not check the subgroup: use `unpackBabyJubPublicKey` for keys
140
+ */
141
+ declare function unpackBabyJubPoint(bytes: Uint8Array): BabyJubPoint;
142
+ /**
143
+ * A public key must be in the prime-order subgroup and not the identity
144
+ */
145
+ declare function isValidBabyJubPublicKey(p: BabyJubPoint): boolean;
146
+ declare function assertBabyJubPublicKey(p: BabyJubPoint): void;
147
+ declare function assertBabyJubPrivateKey(privateKey: bigint): void;
148
+ declare function packBabyJubPublicKey(publicKey: BabyJubPoint): Uint8Array;
149
+ declare function unpackBabyJubPublicKey(bytes: Uint8Array): BabyJubPoint;
150
+ /**
151
+ * Uniform scalar in `[1, BABYJUB_SUBORDER)`, from 64 random bytes
152
+ */
153
+ declare function randomBabyJubScalar(): bigint;
154
+ /**
155
+ * Public key `privateKey · BABYJUB_BASE8`, as circomlib's `BabyPbk` computes it
156
+ */
157
+ declare function babyJubPublicKey(privateKey: bigint): BabyJubPoint;
158
+ declare function generateBabyJubKeyPair(): BabyJubKeyPair;
159
+ /**
160
+ * Derive a key pair from a secret of at least 16 bytes, such as
161
+ * `derivePrfSecret()`'s output. The scalar is
162
+ * `HKDF-SHA256(secret, info = "w3pk-babyjub-v1", 64 bytes) mod (l - 1) + 1`
163
+ */
164
+ declare function deriveBabyJubKeyPair(secret: Uint8Array): BabyJubKeyPair;
165
+ /**
166
+ * Smallest `m` in `[0, maxValue]` with `m · BABYJUB_BASE8 = point`, by
167
+ * baby-step giant-step, or `null` when there is none. `maxValue` is at
168
+ * most 2^32, which takes about 2^17 point additions
169
+ */
170
+ declare function babyJubDiscreteLog(point: BabyJubPoint, maxValue: number): bigint | null;
171
+
172
+ /**
173
+ * Exponential ElGamal over Baby Jubjub
174
+ * Enc(m; r) = (r · B, m · B + r · PK), with B = BABYJUB_BASE8
175
+ */
176
+
177
+ interface ElGamalCiphertext {
178
+ /** `r · B` */
179
+ c1: BabyJubPoint;
180
+ /** `m · B + r · PK` */
181
+ c2: BabyJubPoint;
182
+ }
183
+ /**
184
+ * Encrypt `message` in `[0, l)` to `publicKey`. `r` defaults to a fresh
185
+ * random scalar; pass it when a proof needs it as a witness
186
+ */
187
+ declare function elgamalEncrypt(publicKey: BabyJubPoint, message: bigint, r?: bigint): ElGamalCiphertext;
188
+ /**
189
+ * Ciphertext of `m1 + m2` under the same key, with randomness `r1 + r2`
190
+ */
191
+ declare function elgamalAdd(a: ElGamalCiphertext, b: ElGamalCiphertext): ElGamalCiphertext;
192
+ /**
193
+ * Same plaintext under fresh randomness: adds an encryption of 0 with `r`
194
+ */
195
+ declare function elgamalRerandomize(publicKey: BabyJubPoint, ciphertext: ElGamalCiphertext, r?: bigint): ElGamalCiphertext;
196
+ /**
197
+ * Recover `m · B = c2 - privateKey · c1`
198
+ */
199
+ declare function elgamalDecryptToPoint(privateKey: bigint, ciphertext: ElGamalCiphertext): BabyJubPoint;
200
+ /**
201
+ * Decrypt a message known to be in `[0, maxValue]`, such as a tally.
202
+ * Throws when the plaintext is out of range
203
+ */
204
+ declare function elgamalDecrypt(privateKey: bigint, ciphertext: ElGamalCiphertext, maxValue: number): bigint;
205
+
206
+ /**
207
+ * Custom error classes for better error handling
208
+ */
209
+ declare class Web3PasskeyError extends Error {
210
+ code: string;
211
+ originalError?: unknown | undefined;
212
+ constructor(message: string, code: string, originalError?: unknown | undefined);
213
+ }
214
+ type ZkArtifactName = "wasm" | "zkey";
215
+ /**
216
+ * A circuit artifact's IPFS CID doesn't match the CID pinned onchain,
217
+ * so it isn't the circuit the app chose.
218
+ */
219
+ declare class ZkArtifactMismatchError extends Web3PasskeyError {
220
+ artifact: ZkArtifactName;
221
+ expectedCid: string;
222
+ actualCid: string;
223
+ constructor(artifact: ZkArtifactName, expectedCid: string, actualCid: string);
224
+ }
225
+
226
+ /**
227
+ * Circuit artifact verification against CIDs pinned onchain
228
+ */
229
+
230
+ /** Artifact bytes, or a URL to fetch them from */
231
+ type ZkArtifactSource = ArrayBufferView | ArrayBuffer | string;
232
+ type ZkArtifactSources = Record<ZkArtifactName, ZkArtifactSource>;
233
+ /**
234
+ * IPFS CIDv1 strings in base32, as `ipfs add --cid-version 1` prints them,
235
+ * compared as exact strings
236
+ */
237
+ type ZkArtifactPins = Record<ZkArtifactName, string>;
238
+ type ZkArtifactBytes = Record<ZkArtifactName, Uint8Array>;
239
+ /**
240
+ * Any contract with the build registry's `getCidByVersion(string)`,
241
+ * such as an ethers `Contract`
242
+ */
243
+ interface ZkArtifactRegistry {
244
+ getCidByVersion(key: string): Promise<string>;
245
+ }
246
+ /**
247
+ * Reads the pinned CIDs of a circuit's artifacts from a registry with the
248
+ * build registry's interface, under the given keys
249
+ *
250
+ * @throws Web3PasskeyError `ZK_ARTIFACT_NOT_PINNED` if a key has no CID
251
+ */
252
+ declare function readZkArtifactPins(registry: ZkArtifactRegistry, keys: Record<ZkArtifactName, string>): Promise<ZkArtifactPins>;
253
+ /**
254
+ * Computes the IPFS CIDs of a circuit's `.wasm` and `.zkey` and checks them
255
+ * against the pinned CIDs. Prove with the returned bytes, not by fetching
256
+ * the URLs again, so the checked artifacts are the ones used.
257
+ *
258
+ * @throws ZkArtifactMismatchError if an artifact's CID differs from its pin
259
+ */
260
+ declare function verifyZkArtifacts(artifacts: ZkArtifactSources, pins: ZkArtifactPins): Promise<ZkArtifactBytes>;
261
+
89
262
  /**
90
263
  * Zero-Knowledge Proof Module for w3pk SDK
91
264
  * Enables privacy-preserving proofs
@@ -151,7 +324,7 @@ declare class ZKProofModule {
151
324
  */
152
325
  verifyNFTOwnership(proof: ZKProof, expectedContract: string, expectedHoldersRoot: string, expectedMinBalance?: bigint): Promise<boolean>;
153
326
  /**
154
- * Create a Pedersen commitment for hiding values
327
+ * Create a Poseidon commitment for hiding values
155
328
  */
156
329
  createCommitment(value: bigint, blinding: bigint): Promise<string>;
157
330
  /**
@@ -172,4 +345,4 @@ declare class ZKProofModule {
172
345
  get isAvailable(): boolean;
173
346
  }
174
347
 
175
- export { type CircuitArtifacts, type MembershipProofInput, type NFTOwnershipProofInput, type OwnershipProofInput, type ProofType, type RangeProofInput, type ThresholdProofInput, type VerificationResult, type ZKProof, type ZKProofConfig, ZKProofModule };
348
+ export { BABYJUB_A, BABYJUB_BASE8, BABYJUB_D, BABYJUB_FIELD, BABYJUB_GENERATOR, BABYJUB_IDENTITY, BABYJUB_ORDER, BABYJUB_SUBORDER, type BabyJubKeyPair, type BabyJubPoint, type CircuitArtifacts, type ElGamalCiphertext, type MembershipProofInput, type NFTOwnershipProofInput, type OwnershipProofInput, type ProofType, type RangeProofInput, type ThresholdProofInput, type VerificationResult, type ZKProof, type ZKProofConfig, ZKProofModule, type ZkArtifactBytes, ZkArtifactMismatchError, type ZkArtifactName, type ZkArtifactPins, type ZkArtifactRegistry, type ZkArtifactSource, type ZkArtifactSources, assertBabyJubPrivateKey, assertBabyJubPublicKey, babyJubAdd, babyJubDiscreteLog, babyJubEquals, babyJubMul, babyJubNeg, babyJubPublicKey, deriveBabyJubKeyPair, elgamalAdd, elgamalDecrypt, elgamalDecryptToPoint, elgamalEncrypt, elgamalRerandomize, generateBabyJubKeyPair, isInBabyJubSubgroup, isOnBabyJub, isValidBabyJubPublicKey, packBabyJubPoint, packBabyJubPublicKey, randomBabyJubScalar, readZkArtifactPins, unpackBabyJubPoint, unpackBabyJubPublicKey, verifyZkArtifacts };