@zkproofport-app/sdk 0.1.3-beta.1 → 0.2.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.
- package/README.md +80 -98
- package/dist/ProofportSDK.d.ts +0 -74
- package/dist/constants.d.ts +0 -42
- package/dist/index.esm.js +1 -243
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -243
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -243
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +0 -70
- package/dist/verifier.d.ts +0 -77
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -138,7 +138,6 @@ export interface ProofRequest {
|
|
|
138
138
|
* numPublicInputs: 2,
|
|
139
139
|
* verifierAddress: '0x5678...',
|
|
140
140
|
* chainId: 84532,
|
|
141
|
-
* nullifier: '0x9abc...',
|
|
142
141
|
* timestamp: Date.now()
|
|
143
142
|
* };
|
|
144
143
|
* ```
|
|
@@ -164,8 +163,6 @@ export interface ProofResponse {
|
|
|
164
163
|
verifierAddress?: string;
|
|
165
164
|
/** Chain ID where verifier contract is deployed (provided by mobile app) */
|
|
166
165
|
chainId?: number;
|
|
167
|
-
/** Nullifier for proof uniqueness (prevents double-use, derived from scope) */
|
|
168
|
-
nullifier?: string;
|
|
169
166
|
}
|
|
170
167
|
/**
|
|
171
168
|
* Parsed and formatted proof data ready for on-chain verification.
|
|
@@ -264,13 +261,6 @@ export interface ProofportConfig {
|
|
|
264
261
|
relayUrl?: string;
|
|
265
262
|
/** Custom verifier contract addresses per circuit type (overrides defaults) */
|
|
266
263
|
verifiers?: Partial<Record<CircuitType, VerifierContract>>;
|
|
267
|
-
/** Nullifier registry contract config. Required for checkNullifier() and getNullifierDetails(). */
|
|
268
|
-
nullifierRegistry?: {
|
|
269
|
-
/** Registry contract address */
|
|
270
|
-
address: string;
|
|
271
|
-
/** Chain ID where registry is deployed */
|
|
272
|
-
chainId: number;
|
|
273
|
-
};
|
|
274
264
|
}
|
|
275
265
|
/**
|
|
276
266
|
* Parsed deep link URL components.
|
|
@@ -288,65 +278,6 @@ export interface DeepLinkComponents {
|
|
|
288
278
|
/** Query parameters as key-value pairs */
|
|
289
279
|
params: Record<string, string>;
|
|
290
280
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Nullifier verification status returned by smart contract.
|
|
293
|
-
*
|
|
294
|
-
* Mirrors the NullifierVerifyStatus enum in the ZKProofportNullifierRegistry contract.
|
|
295
|
-
* Indicates the result of verifying and registering a proof's nullifier on-chain.
|
|
296
|
-
*
|
|
297
|
-
* - `verified_and_registered`: Proof verified and nullifier registered successfully
|
|
298
|
-
* - `already_registered`: Proof verified but nullifier was already used (duplicate)
|
|
299
|
-
* - `expired_and_reregistered`: Previous nullifier expired, new one registered
|
|
300
|
-
* - `verification_failed`: Proof verification failed (invalid proof)
|
|
301
|
-
* - `circuit_not_found`: Circuit not registered in the registry
|
|
302
|
-
*/
|
|
303
|
-
export type NullifierVerifyStatus = 'verified_and_registered' | 'already_registered' | 'expired_and_reregistered' | 'verification_failed' | 'circuit_not_found';
|
|
304
|
-
/**
|
|
305
|
-
* On-chain nullifier record from smart contract storage.
|
|
306
|
-
*
|
|
307
|
-
* Contains information about a registered nullifier retrieved from
|
|
308
|
-
* the ZKProofportNullifierRegistry contract.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```typescript
|
|
312
|
-
* const record: NullifierRecord = {
|
|
313
|
-
* registeredAt: 1707234567,
|
|
314
|
-
* scope: '0xabcd...',
|
|
315
|
-
* circuitId: '0x1234...'
|
|
316
|
-
* };
|
|
317
|
-
* ```
|
|
318
|
-
*/
|
|
319
|
-
export interface NullifierRecord {
|
|
320
|
-
/** Unix timestamp (seconds) when nullifier was registered */
|
|
321
|
-
registeredAt: number;
|
|
322
|
-
/** Scope bytes32 (application identifier) */
|
|
323
|
-
scope: string;
|
|
324
|
-
/** Circuit ID bytes32 (circuit identifier) */
|
|
325
|
-
circuitId: string;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* ZKProofportNullifierRegistry smart contract configuration.
|
|
329
|
-
*
|
|
330
|
-
* Contains the address and ABI for the nullifier registry contract,
|
|
331
|
-
* which tracks used nullifiers to prevent proof replay attacks.
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* ```typescript
|
|
335
|
-
* const registryConfig: NullifierRegistryConfig = {
|
|
336
|
-
* address: '0x5678...',
|
|
337
|
-
* chainId: 84532,
|
|
338
|
-
* abi: ZKPROOFPORT_NULLIFIER_REGISTRY_ABI
|
|
339
|
-
* };
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
export interface NullifierRegistryConfig {
|
|
343
|
-
/** Registry contract address (checksummed) */
|
|
344
|
-
address: string;
|
|
345
|
-
/** Chain ID where registry is deployed */
|
|
346
|
-
chainId: number;
|
|
347
|
-
/** Contract ABI (ethers v6 format) */
|
|
348
|
-
abi: string[];
|
|
349
|
-
}
|
|
350
281
|
/**
|
|
351
282
|
* Challenge response from relay server.
|
|
352
283
|
*
|
|
@@ -415,7 +346,6 @@ export interface RelayProofResult {
|
|
|
415
346
|
publicInputs?: string[];
|
|
416
347
|
verifierAddress?: string;
|
|
417
348
|
chainId?: number;
|
|
418
|
-
nullifier?: string;
|
|
419
349
|
circuit?: string;
|
|
420
350
|
/** Present when status is 'failed' */
|
|
421
351
|
error?: string;
|
package/dist/verifier.d.ts
CHANGED
|
@@ -145,80 +145,3 @@ export declare function getVerifierChainId(circuit: CircuitType, customVerifier?
|
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
147
|
export declare function extractScopeFromPublicInputs(publicInputsHex: string[], circuit?: string): string | null;
|
|
148
|
-
/**
|
|
149
|
-
* Extract nullifier value from public inputs array.
|
|
150
|
-
*
|
|
151
|
-
* The nullifier is a bytes32 value encoded across 32 consecutive field elements
|
|
152
|
-
* in the public inputs. The exact position depends on the circuit type.
|
|
153
|
-
* Nullifiers are used for duplicate proof detection and must be unique per user+scope.
|
|
154
|
-
*
|
|
155
|
-
* @param publicInputsHex - Array of public input hex strings (zero-padded to 32 bytes)
|
|
156
|
-
* @param circuit - Optional circuit identifier to determine field positions
|
|
157
|
-
* @returns Reconstructed nullifier as hex string with 0x prefix, or null if inputs are insufficient
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* const nullifier = extractNullifierFromPublicInputs(publicInputsHex, 'coinbase_attestation');
|
|
162
|
-
* console.log(nullifier); // '0xabcd1234...'
|
|
163
|
-
*
|
|
164
|
-
* // Check if nullifier is already registered
|
|
165
|
-
* const isRegistered = await isNullifierRegistered(nullifier, registryAddress, provider);
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
export declare function extractNullifierFromPublicInputs(publicInputsHex: string[], circuit?: string): string | null;
|
|
169
|
-
/**
|
|
170
|
-
* Check if a nullifier is already registered on-chain in the ZKProofport nullifier registry.
|
|
171
|
-
*
|
|
172
|
-
* This function queries the on-chain nullifier registry contract to determine if a nullifier
|
|
173
|
-
* has been used before. This is used to prevent duplicate proof submissions from the same user
|
|
174
|
-
* for the same scope.
|
|
175
|
-
*
|
|
176
|
-
* @param nullifier - The nullifier hash as hex string with 0x prefix
|
|
177
|
-
* @param registryAddress - ZKProofportNullifierRegistry contract address
|
|
178
|
-
* @param provider - ethers.js Provider instance (v5 or v6 compatible)
|
|
179
|
-
* @returns Promise resolving to true if nullifier is registered, false otherwise
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const nullifier = extractNullifierFromPublicInputs(publicInputsHex, circuit);
|
|
184
|
-
* const isRegistered = await isNullifierRegistered(
|
|
185
|
-
* nullifier,
|
|
186
|
-
* '0x...',
|
|
187
|
-
* provider
|
|
188
|
-
* );
|
|
189
|
-
*
|
|
190
|
-
* if (isRegistered) {
|
|
191
|
-
* console.log('This nullifier has already been used');
|
|
192
|
-
* }
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
export declare function isNullifierRegistered(nullifier: string, registryAddress: string, provider: any): Promise<boolean>;
|
|
196
|
-
/**
|
|
197
|
-
* Get detailed information about a registered nullifier from the on-chain registry.
|
|
198
|
-
*
|
|
199
|
-
* This function retrieves the registration timestamp, scope, and circuit ID for a nullifier
|
|
200
|
-
* that has been registered on-chain. This metadata is useful for auditing and analytics.
|
|
201
|
-
*
|
|
202
|
-
* @param nullifier - The nullifier hash as hex string with 0x prefix
|
|
203
|
-
* @param registryAddress - ZKProofportNullifierRegistry contract address
|
|
204
|
-
* @param provider - ethers.js Provider instance (v5 or v6 compatible)
|
|
205
|
-
* @returns Promise resolving to nullifier info object, or null if not registered
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```typescript
|
|
209
|
-
* const info = await getNullifierInfo(nullifier, registryAddress, provider);
|
|
210
|
-
*
|
|
211
|
-
* if (info) {
|
|
212
|
-
* console.log('Registered at:', new Date(info.registeredAt * 1000));
|
|
213
|
-
* console.log('Scope:', info.scope);
|
|
214
|
-
* console.log('Circuit:', info.circuitId);
|
|
215
|
-
* } else {
|
|
216
|
-
* console.log('Nullifier not registered');
|
|
217
|
-
* }
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
export declare function getNullifierInfo(nullifier: string, registryAddress: string, provider: any): Promise<{
|
|
221
|
-
registeredAt: number;
|
|
222
|
-
scope: string;
|
|
223
|
-
circuitId: string;
|
|
224
|
-
} | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkproofport-app/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ZKProofport SDK for requesting zero-knowledge proofs from the ZKProofport mobile app and verifying them on-chain",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|