@zkproofport-app/sdk 0.1.2-beta.1 → 0.2.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.
- package/README.md +67 -98
- package/dist/ProofportSDK.d.ts +24 -138
- package/dist/constants.d.ts +0 -42
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +42 -354
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +42 -354
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -354
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +22 -104
- 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.
|
|
@@ -289,115 +279,44 @@ export interface DeepLinkComponents {
|
|
|
289
279
|
params: Record<string, string>;
|
|
290
280
|
}
|
|
291
281
|
/**
|
|
292
|
-
*
|
|
282
|
+
* Challenge response from relay server.
|
|
293
283
|
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
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.
|
|
284
|
+
* The relay server issues a random challenge that must be signed
|
|
285
|
+
* by the user's wallet to authenticate proof requests.
|
|
332
286
|
*
|
|
333
287
|
* @example
|
|
334
288
|
* ```typescript
|
|
335
|
-
* const
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* abi: ZKPROOFPORT_NULLIFIER_REGISTRY_ABI
|
|
289
|
+
* const challenge: ChallengeResponse = {
|
|
290
|
+
* challenge: '0xabcdef...',
|
|
291
|
+
* expiresAt: 1707234567890
|
|
339
292
|
* };
|
|
340
293
|
* ```
|
|
341
294
|
*/
|
|
342
|
-
export interface
|
|
343
|
-
/**
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
|
|
347
|
-
/** Contract ABI (ethers v6 format) */
|
|
348
|
-
abi: string[];
|
|
295
|
+
export interface ChallengeResponse {
|
|
296
|
+
/** Hex-encoded 32-byte random challenge */
|
|
297
|
+
challenge: string;
|
|
298
|
+
/** Unix timestamp (ms) when challenge expires */
|
|
299
|
+
expiresAt: number;
|
|
349
300
|
}
|
|
350
301
|
/**
|
|
351
|
-
*
|
|
302
|
+
* Wallet signer interface for challenge signing.
|
|
303
|
+
* Compatible with ethers v6 Signer.
|
|
352
304
|
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
305
|
+
* Any object implementing `signMessage` and `getAddress` can be used,
|
|
306
|
+
* including ethers v6 `Signer` instances.
|
|
355
307
|
*
|
|
356
308
|
* @example
|
|
357
309
|
* ```typescript
|
|
358
|
-
*
|
|
359
|
-
* clientId: 'your-client-id',
|
|
360
|
-
* apiKey: 'your-api-key'
|
|
361
|
-
* };
|
|
362
|
-
* ```
|
|
363
|
-
*/
|
|
364
|
-
export interface AuthCredentials {
|
|
365
|
-
/** Client ID identifying the application */
|
|
366
|
-
clientId: string;
|
|
367
|
-
/** API key for authentication */
|
|
368
|
-
apiKey: string;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* JWT authentication token received from the API server.
|
|
372
|
-
*
|
|
373
|
-
* Contains the JWT token and metadata about the authenticated session,
|
|
374
|
-
* including tier information, expiration time, and associated identifiers.
|
|
310
|
+
* import { BrowserProvider } from 'ethers';
|
|
375
311
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* token: 'eyJhbGc...',
|
|
380
|
-
* clientId: 'your-client-id',
|
|
381
|
-
* dappId: 'app-123',
|
|
382
|
-
* tier: 'plan1',
|
|
383
|
-
* expiresIn: 3600,
|
|
384
|
-
* expiresAt: 1707234567890
|
|
385
|
-
* };
|
|
312
|
+
* const provider = new BrowserProvider(window.ethereum);
|
|
313
|
+
* const signer = await provider.getSigner();
|
|
314
|
+
* // signer implements WalletSigner
|
|
386
315
|
* ```
|
|
387
316
|
*/
|
|
388
|
-
export interface
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
/** Client ID that the token was issued for */
|
|
392
|
-
clientId: string;
|
|
393
|
-
/** DApp ID associated with this client */
|
|
394
|
-
dappId: string;
|
|
395
|
-
/** Service tier (free, credit, plan1, plan2) */
|
|
396
|
-
tier: string;
|
|
397
|
-
/** Token lifetime in seconds (typically 3600 = 1 hour) */
|
|
398
|
-
expiresIn: number;
|
|
399
|
-
/** Unix timestamp (ms) when the token expires */
|
|
400
|
-
expiresAt: number;
|
|
317
|
+
export interface WalletSigner {
|
|
318
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
319
|
+
getAddress(): Promise<string>;
|
|
401
320
|
}
|
|
402
321
|
/**
|
|
403
322
|
* Result from creating a proof request via relay.
|
|
@@ -427,7 +346,6 @@ export interface RelayProofResult {
|
|
|
427
346
|
publicInputs?: string[];
|
|
428
347
|
verifierAddress?: string;
|
|
429
348
|
chainId?: number;
|
|
430
|
-
nullifier?: string;
|
|
431
349
|
circuit?: string;
|
|
432
350
|
/** Present when status is 'failed' */
|
|
433
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.0",
|
|
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",
|