@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/README.md
CHANGED
|
@@ -5,17 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
TypeScript SDK for requesting zero-knowledge proofs from the [ZKProofport](https://zkproofport.com) mobile app and verifying them on-chain.
|
|
7
7
|
|
|
8
|
-
> **Beta** — Currently deployed on **Base Sepolia (testnet)** only. APIs may change before the stable release.
|
|
9
|
-
|
|
10
8
|
## How It Works
|
|
11
9
|
|
|
12
10
|
```
|
|
13
11
|
┌──────────────┐ ┌─────────┐ ┌──────────────┐ ┌──────────────────┐
|
|
14
12
|
│ Your Web App │────>│ SDK │────>│ Relay Server │────>│ ZKProofport App │
|
|
15
13
|
│ │ │ │ │ │ │ │
|
|
16
|
-
│ │ │
|
|
17
|
-
│ │ │ create
|
|
18
|
-
│ │ │ request
|
|
14
|
+
│ │ │ setSigner│ │ issues ID, │ │ - Connects wallet│
|
|
15
|
+
│ │ │ + create │ │ tracks state │ │ - Fetches data │
|
|
16
|
+
│ │ │ request │ │ │ │ - Generates proof│
|
|
19
17
|
└──────┬───────┘ └─────────┘ └──────┬───────┘ └────────┬─────────┘
|
|
20
18
|
│ │ │
|
|
21
19
|
│ │<─────────────────────┘
|
|
@@ -24,18 +22,18 @@ TypeScript SDK for requesting zero-knowledge proofs from the [ZKProofport](https
|
|
|
24
22
|
│ v
|
|
25
23
|
│ ┌──────────────────────────────────────────────────┐
|
|
26
24
|
│ │ SDK receives result (WebSocket / polling) │
|
|
27
|
-
│ │ (proof, publicInputs,
|
|
25
|
+
│ │ (proof, publicInputs, status) │
|
|
28
26
|
│ └─────────────────────┬────────────────────────────┘
|
|
29
27
|
│ │
|
|
30
28
|
v v
|
|
31
29
|
┌──────────────┐ ┌──────────────────┐ ┌───────────────────┐
|
|
32
30
|
│ Verify │────>│ On-chain verify │────>│ Access granted │
|
|
33
|
-
│ on-chain │ │ (Base
|
|
31
|
+
│ on-chain │ │ (Base Mainnet) │ │ or denied │
|
|
34
32
|
└──────────────┘ └──────────────────┘ └───────────────────┘
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
1. Your app
|
|
38
|
-
2. The
|
|
35
|
+
1. Your app sets a wallet signer and creates a proof request via the SDK
|
|
36
|
+
2. The SDK authenticates with the relay using challenge-signature (EIP-191) and gets a tracked request ID
|
|
39
37
|
3. The SDK displays a QR code (desktop) or opens the deep link (mobile)
|
|
40
38
|
4. The user opens the ZKProofport app, which generates the ZK proof
|
|
41
39
|
5. The proof result flows back through the relay to your app via WebSocket (or polling)
|
|
@@ -44,11 +42,9 @@ TypeScript SDK for requesting zero-knowledge proofs from the [ZKProofport](https
|
|
|
44
42
|
## Installation
|
|
45
43
|
|
|
46
44
|
```bash
|
|
47
|
-
npm install @zkproofport-app/sdk
|
|
45
|
+
npm install @zkproofport-app/sdk
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
> Published under the `beta` dist-tag. Use `@beta` to install.
|
|
51
|
-
|
|
52
48
|
**Peer dependency (required for on-chain verification):**
|
|
53
49
|
|
|
54
50
|
```bash
|
|
@@ -59,12 +55,15 @@ npm install ethers
|
|
|
59
55
|
|
|
60
56
|
```typescript
|
|
61
57
|
import { ProofportSDK } from '@zkproofport-app/sdk';
|
|
58
|
+
import { BrowserProvider } from 'ethers';
|
|
62
59
|
|
|
63
60
|
// 1. Initialize
|
|
64
61
|
const sdk = ProofportSDK.create();
|
|
65
62
|
|
|
66
|
-
// 2.
|
|
67
|
-
|
|
63
|
+
// 2. Set wallet signer (ethers v6 Signer)
|
|
64
|
+
const provider = new BrowserProvider(window.ethereum);
|
|
65
|
+
const signer = await provider.getSigner();
|
|
66
|
+
sdk.setSigner(signer);
|
|
68
67
|
|
|
69
68
|
// 3. Create proof request via relay
|
|
70
69
|
const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -97,7 +96,7 @@ Proves that a user has completed Coinbase KYC identity verification without reve
|
|
|
97
96
|
|
|
98
97
|
| Field | Type | Required | Description |
|
|
99
98
|
|-------|------|----------|-------------|
|
|
100
|
-
| `scope` | `string` | Yes | Application-specific identifier (e.g., your domain).
|
|
99
|
+
| `scope` | `string` | Yes | Application-specific identifier (e.g., your domain). Ensures proof uniqueness per app. |
|
|
101
100
|
|
|
102
101
|
```typescript
|
|
103
102
|
const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -135,29 +134,34 @@ import { ProofportSDK } from '@zkproofport-app/sdk';
|
|
|
135
134
|
const sdk = ProofportSDK.create();
|
|
136
135
|
```
|
|
137
136
|
|
|
138
|
-
`ProofportSDK.create()` returns an SDK instance pre-configured with the relay server
|
|
137
|
+
`ProofportSDK.create()` returns an SDK instance pre-configured with the relay server and verifier contracts. No configuration needed.
|
|
139
138
|
|
|
140
|
-
### Step 2:
|
|
139
|
+
### Step 2: Set Wallet Signer
|
|
141
140
|
|
|
142
|
-
|
|
141
|
+
The SDK uses challenge-signature authentication (EIP-191). Set a wallet signer that can sign messages:
|
|
143
142
|
|
|
144
143
|
```typescript
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
import { BrowserProvider } from 'ethers';
|
|
145
|
+
|
|
146
|
+
const provider = new BrowserProvider(window.ethereum);
|
|
147
|
+
const signer = await provider.getSigner();
|
|
148
|
+
sdk.setSigner(signer);
|
|
149
|
+
```
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
The `WalletSigner` interface requires two methods:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
interface WalletSigner {
|
|
155
|
+
signMessage(message: string): Promise<string>;
|
|
156
|
+
getAddress(): Promise<string>;
|
|
157
|
+
}
|
|
154
158
|
```
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
Any ethers v5/v6 `Signer` is compatible.
|
|
157
161
|
|
|
158
162
|
### Step 3: Create Request (via Relay)
|
|
159
163
|
|
|
160
|
-
`createRelayRequest`
|
|
164
|
+
`createRelayRequest` authenticates with the relay (challenge-signature), creates a tracked proof request, and returns a deep link.
|
|
161
165
|
|
|
162
166
|
```typescript
|
|
163
167
|
const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -201,7 +205,7 @@ await sdk.renderQRCodeToCanvas(canvasElement, relay.deepLink, { width: 400 });
|
|
|
201
205
|
const { size, withinLimit } = sdk.checkQRCodeSize(relay.deepLink);
|
|
202
206
|
```
|
|
203
207
|
|
|
204
|
-
**Mobile:** On mobile browsers,
|
|
208
|
+
**Mobile:** On mobile browsers, redirect directly to the deep link instead of showing a QR code:
|
|
205
209
|
|
|
206
210
|
```typescript
|
|
207
211
|
if (ProofportSDK.isMobile()) {
|
|
@@ -277,44 +281,22 @@ if (result.status === 'completed') {
|
|
|
277
281
|
const verification = await sdk.verifyResponseOnChain(response);
|
|
278
282
|
```
|
|
279
283
|
|
|
280
|
-
### Step 7: Check Nullifier (Optional)
|
|
281
|
-
|
|
282
|
-
Nullifiers prevent the same user from submitting duplicate proofs for the same scope. The SDK is pre-configured with the nullifier registry contract.
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
// Extract nullifier from proof result
|
|
286
|
-
const nullifier = sdk.extractNullifier(result.publicInputs, result.circuit);
|
|
287
|
-
const scope = sdk.extractScope(result.publicInputs, result.circuit);
|
|
288
|
-
|
|
289
|
-
// Check if already used
|
|
290
|
-
const isDuplicate = await sdk.checkNullifier(nullifier);
|
|
291
|
-
if (isDuplicate) {
|
|
292
|
-
console.log('This user has already submitted a proof for this scope');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Get registration details
|
|
296
|
-
const info = await sdk.getNullifierDetails(nullifier);
|
|
297
|
-
if (info) {
|
|
298
|
-
console.log('Registered at:', new Date(info.registeredAt * 1000));
|
|
299
|
-
console.log('Circuit:', info.circuitId);
|
|
300
|
-
console.log('Scope:', info.scope);
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
284
|
## Complete Example
|
|
305
285
|
|
|
306
286
|
End-to-end integration using the relay flow:
|
|
307
287
|
|
|
308
288
|
```typescript
|
|
309
289
|
import { ProofportSDK } from '@zkproofport-app/sdk';
|
|
290
|
+
import { BrowserProvider } from 'ethers';
|
|
310
291
|
|
|
311
292
|
async function verifyUser() {
|
|
312
|
-
// Initialize
|
|
293
|
+
// Initialize
|
|
313
294
|
const sdk = ProofportSDK.create();
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
295
|
+
|
|
296
|
+
// Set wallet signer
|
|
297
|
+
const provider = new BrowserProvider(window.ethereum);
|
|
298
|
+
const signer = await provider.getSigner();
|
|
299
|
+
sdk.setSigner(signer);
|
|
318
300
|
|
|
319
301
|
// Create proof request via relay
|
|
320
302
|
const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -357,24 +339,24 @@ async function verifyUser() {
|
|
|
357
339
|
}
|
|
358
340
|
```
|
|
359
341
|
|
|
360
|
-
##
|
|
342
|
+
## Configuration
|
|
361
343
|
|
|
362
|
-
|
|
344
|
+
`ProofportSDK.create()` returns a fully configured SDK instance. No manual configuration is needed for standard usage.
|
|
363
345
|
|
|
364
|
-
|
|
346
|
+
For advanced scenarios (e.g., custom verifier deployments), pass a `ProofportConfig`:
|
|
365
347
|
|
|
366
348
|
```typescript
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
349
|
+
const sdk = new ProofportSDK({
|
|
350
|
+
relayUrl: 'https://relay.zkproofport.app',
|
|
351
|
+
verifiers: {
|
|
352
|
+
coinbase_attestation: {
|
|
353
|
+
verifierAddress: '0x...',
|
|
354
|
+
chainId: 8453,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
});
|
|
370
358
|
```
|
|
371
359
|
|
|
372
|
-
## Configuration
|
|
373
|
-
|
|
374
|
-
`ProofportSDK.create()` returns a fully configured SDK instance. No manual configuration is needed for standard usage.
|
|
375
|
-
|
|
376
|
-
For advanced scenarios (e.g., custom verifier deployments), see the `ProofportConfig` type exported by the SDK.
|
|
377
|
-
|
|
378
360
|
## Types Reference
|
|
379
361
|
|
|
380
362
|
All 15 exported types:
|
|
@@ -391,8 +373,8 @@ import type {
|
|
|
391
373
|
QRCodeOptions,
|
|
392
374
|
VerifierContract,
|
|
393
375
|
ProofportConfig,
|
|
394
|
-
|
|
395
|
-
|
|
376
|
+
ChallengeResponse,
|
|
377
|
+
WalletSigner,
|
|
396
378
|
RelayProofRequest,
|
|
397
379
|
RelayProofResult,
|
|
398
380
|
SDKEnvironment,
|
|
@@ -407,31 +389,25 @@ import type {
|
|
|
407
389
|
| `CoinbaseCountryInputs` | Inputs for `coinbase_country_attestation` (`{ scope, countryList, isIncluded, ... }`) |
|
|
408
390
|
| `CircuitInputs` | Union: `CoinbaseKycInputs \| CoinbaseCountryInputs` |
|
|
409
391
|
| `ProofRequest` | Proof request object with `requestId`, `circuit`, `inputs`, metadata, and expiry |
|
|
410
|
-
| `ProofResponse` | Proof response with `status`, `proof`, `publicInputs`, `
|
|
392
|
+
| `ProofResponse` | Proof response with `status`, `proof`, `publicInputs`, `verifierAddress`, `chainId` |
|
|
411
393
|
| `QRCodeOptions` | QR customization: `width`, `margin`, `darkColor`, `lightColor`, `errorCorrectionLevel` |
|
|
412
394
|
| `VerifierContract` | Verifier contract info: `{ address, chainId, abi }` |
|
|
413
|
-
| `ProofportConfig` | SDK configuration
|
|
414
|
-
| `
|
|
415
|
-
| `
|
|
395
|
+
| `ProofportConfig` | SDK configuration: `{ scheme?, relayUrl?, verifiers? }` |
|
|
396
|
+
| `ChallengeResponse` | Challenge from relay: `{ challenge, expiresAt }` |
|
|
397
|
+
| `WalletSigner` | Signer interface: `{ signMessage(msg), getAddress() }` |
|
|
416
398
|
| `RelayProofRequest` | Relay response: `{ requestId, deepLink, status, pollUrl }` |
|
|
417
|
-
| `RelayProofResult` | Relay result: `{ requestId, status, proof?, publicInputs?,
|
|
418
|
-
| `SDKEnvironment` |
|
|
399
|
+
| `RelayProofResult` | Relay result: `{ requestId, status, proof?, publicInputs?, circuit?, error? }` |
|
|
400
|
+
| `SDKEnvironment` | Environment preset (not needed for normal usage) |
|
|
419
401
|
|
|
420
402
|
## Error Handling
|
|
421
403
|
|
|
422
|
-
All async SDK methods throw standard `Error` objects
|
|
404
|
+
All async SDK methods throw standard `Error` objects:
|
|
423
405
|
|
|
424
406
|
```typescript
|
|
425
|
-
try {
|
|
426
|
-
await sdk.login({ clientId: 'bad-id', apiKey: 'bad-key' });
|
|
427
|
-
} catch (err) {
|
|
428
|
-
// "Authentication failed: HTTP 401"
|
|
429
|
-
}
|
|
430
|
-
|
|
431
407
|
try {
|
|
432
408
|
await sdk.createRelayRequest('coinbase_attestation', { scope: 'app.com' });
|
|
433
409
|
} catch (err) {
|
|
434
|
-
// "
|
|
410
|
+
// "Signer not set. Call setSigner() first."
|
|
435
411
|
}
|
|
436
412
|
|
|
437
413
|
try {
|
|
@@ -441,19 +417,12 @@ try {
|
|
|
441
417
|
}
|
|
442
418
|
```
|
|
443
419
|
|
|
444
|
-
|
|
420
|
+
## Networks
|
|
445
421
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
countryList: [],
|
|
451
|
-
isIncluded: true,
|
|
452
|
-
});
|
|
453
|
-
} catch (err) {
|
|
454
|
-
// Relay or input validation error
|
|
455
|
-
}
|
|
456
|
-
```
|
|
422
|
+
| Network | Chain ID | Status |
|
|
423
|
+
|---------|----------|--------|
|
|
424
|
+
| Base Mainnet | 8453 | Production |
|
|
425
|
+
| Base Sepolia | 84532 | Testnet |
|
|
457
426
|
|
|
458
427
|
## Development
|
|
459
428
|
|
package/dist/ProofportSDK.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Proofport SDK - Main class
|
|
3
3
|
*/
|
|
4
|
-
import type { ProofRequest, ProofResponse, CircuitType, CircuitInputs, ProofportConfig, QRCodeOptions,
|
|
4
|
+
import type { ProofRequest, ProofResponse, CircuitType, CircuitInputs, ProofportConfig, QRCodeOptions, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult } from './types';
|
|
5
5
|
import type { SDKEnvironment } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Main SDK class for interacting with the ZKProofport mobile app.
|
|
@@ -12,12 +12,15 @@ import type { SDKEnvironment } from './types';
|
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
14
14
|
* import { ProofportSDK } from '@zkproofport-app/sdk';
|
|
15
|
+
* import { BrowserProvider } from 'ethers';
|
|
15
16
|
*
|
|
16
17
|
* // Initialize SDK (uses production relay by default)
|
|
17
18
|
* const sdk = ProofportSDK.create();
|
|
18
19
|
*
|
|
19
|
-
* //
|
|
20
|
-
*
|
|
20
|
+
* // Set wallet signer for challenge-signature auth
|
|
21
|
+
* const provider = new BrowserProvider(window.ethereum);
|
|
22
|
+
* const signer = await provider.getSigner();
|
|
23
|
+
* sdk.setSigner(signer);
|
|
21
24
|
*
|
|
22
25
|
* // Create proof request via relay
|
|
23
26
|
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -37,9 +40,8 @@ import type { SDKEnvironment } from './types';
|
|
|
37
40
|
export declare class ProofportSDK {
|
|
38
41
|
private config;
|
|
39
42
|
private pendingRequests;
|
|
40
|
-
private
|
|
43
|
+
private signer;
|
|
41
44
|
private relayUrl;
|
|
42
|
-
private nullifierRegistry?;
|
|
43
45
|
private socket;
|
|
44
46
|
/**
|
|
45
47
|
* Creates a new ProofportSDK instance.
|
|
@@ -707,91 +709,48 @@ export declare class ProofportSDK {
|
|
|
707
709
|
*/
|
|
708
710
|
static isMobile(): boolean;
|
|
709
711
|
/**
|
|
710
|
-
*
|
|
712
|
+
* Sets the wallet signer for challenge-signature authentication.
|
|
713
|
+
* The signer will be used to sign challenges from the relay server.
|
|
711
714
|
*
|
|
712
|
-
*
|
|
713
|
-
* that can be used to authenticate relay requests.
|
|
714
|
-
*
|
|
715
|
-
* @param credentials - Client ID and API key
|
|
716
|
-
* @param relayUrl - Relay server URL (e.g., 'https://relay.zkproofport.app')
|
|
717
|
-
* @returns Promise resolving to AuthToken with JWT token and metadata
|
|
718
|
-
* @throws Error if authentication fails
|
|
715
|
+
* @param signer - Wallet signer (ethers v6 Signer or compatible object with signMessage/getAddress)
|
|
719
716
|
*
|
|
720
717
|
* @example
|
|
721
718
|
* ```typescript
|
|
722
|
-
*
|
|
723
|
-
* { clientId: 'your-client-id', apiKey: 'your-api-key' },
|
|
724
|
-
* 'https://relay.zkproofport.app'
|
|
725
|
-
* );
|
|
726
|
-
* console.log('Token:', auth.token);
|
|
727
|
-
* console.log('Expires in:', auth.expiresIn, 'seconds');
|
|
728
|
-
* ```
|
|
729
|
-
*/
|
|
730
|
-
static authenticate(credentials: AuthCredentials, relayUrl: string): Promise<AuthToken>;
|
|
731
|
-
/**
|
|
732
|
-
* Checks if an auth token is still valid (not expired).
|
|
733
|
-
*
|
|
734
|
-
* @param auth - AuthToken to check
|
|
735
|
-
* @returns True if the token has not expired
|
|
719
|
+
* import { BrowserProvider } from 'ethers';
|
|
736
720
|
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* auth = await ProofportSDK.authenticate(credentials, relayUrl);
|
|
741
|
-
* }
|
|
721
|
+
* const provider = new BrowserProvider(window.ethereum);
|
|
722
|
+
* const signer = await provider.getSigner();
|
|
723
|
+
* sdk.setSigner(signer);
|
|
742
724
|
* ```
|
|
743
725
|
*/
|
|
744
|
-
|
|
726
|
+
setSigner(signer: WalletSigner): void;
|
|
745
727
|
/**
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
* Instance method that authenticates via the relay server and stores
|
|
749
|
-
* the JWT token internally, so subsequent relay requests are automatically authenticated.
|
|
750
|
-
*
|
|
751
|
-
* @param credentials - Client ID and API key
|
|
752
|
-
* @returns Promise resolving to AuthToken
|
|
753
|
-
* @throws Error if authentication fails or relayUrl is not configured
|
|
754
|
-
*
|
|
755
|
-
* @example
|
|
756
|
-
* ```typescript
|
|
757
|
-
* const sdk = ProofportSDK.create('production');
|
|
728
|
+
* Fetches a random challenge from the relay server.
|
|
729
|
+
* The challenge must be signed and included in proof requests.
|
|
758
730
|
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* ```
|
|
762
|
-
*/
|
|
763
|
-
login(credentials: AuthCredentials): Promise<AuthToken>;
|
|
764
|
-
/**
|
|
765
|
-
* Logs out by clearing the stored authentication token.
|
|
766
|
-
*/
|
|
767
|
-
logout(): void;
|
|
768
|
-
/**
|
|
769
|
-
* Returns whether the SDK instance is currently authenticated with a valid token.
|
|
770
|
-
*/
|
|
771
|
-
isAuthenticated(): boolean;
|
|
772
|
-
/**
|
|
773
|
-
* Returns the current auth token, or null if not authenticated.
|
|
731
|
+
* @returns Promise resolving to ChallengeResponse with challenge hex and expiry
|
|
732
|
+
* @throws Error if relayUrl is not configured
|
|
774
733
|
*/
|
|
775
|
-
|
|
734
|
+
getChallenge(): Promise<ChallengeResponse>;
|
|
776
735
|
/**
|
|
777
736
|
* Creates a proof request through the relay server.
|
|
778
737
|
*
|
|
779
738
|
* This is the recommended way to create proof requests. The relay server:
|
|
780
739
|
* - Issues a server-side requestId (validated by the mobile app)
|
|
781
740
|
* - Tracks request status in Redis
|
|
782
|
-
* - Handles credit deduction and tier enforcement
|
|
783
741
|
* - Builds the deep link with relay callback URL
|
|
742
|
+
* - Stores inputs hash for deep link integrity verification
|
|
784
743
|
*
|
|
785
744
|
* @param circuit - Circuit type identifier
|
|
786
745
|
* @param inputs - Circuit-specific inputs
|
|
787
746
|
* @param options - Request options (message, dappName, dappIcon, nonce)
|
|
788
747
|
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
789
|
-
* @throws Error if not
|
|
748
|
+
* @throws Error if signer not set or relay request fails
|
|
790
749
|
*
|
|
791
750
|
* @example
|
|
792
751
|
* ```typescript
|
|
793
752
|
* const sdk = ProofportSDK.create();
|
|
794
|
-
*
|
|
753
|
+
* sdk.setSigner(signer);
|
|
795
754
|
*
|
|
796
755
|
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
797
756
|
* scope: 'myapp.com'
|
|
@@ -857,7 +816,7 @@ export declare class ProofportSDK {
|
|
|
857
816
|
* @param callbacks.onResult - Called when proof is completed or failed
|
|
858
817
|
* @param callbacks.onError - Called on errors
|
|
859
818
|
* @returns Unsubscribe function to clean up the connection
|
|
860
|
-
* @throws Error if
|
|
819
|
+
* @throws Error if relayUrl not set or socket.io-client not installed
|
|
861
820
|
*
|
|
862
821
|
* @example
|
|
863
822
|
* ```typescript
|
|
@@ -914,27 +873,6 @@ export declare class ProofportSDK {
|
|
|
914
873
|
* Disconnects the Socket.IO connection if active.
|
|
915
874
|
*/
|
|
916
875
|
disconnect(): void;
|
|
917
|
-
/**
|
|
918
|
-
* Extracts the nullifier from proof public inputs.
|
|
919
|
-
*
|
|
920
|
-
* The nullifier is a bytes32 value derived from the user's address and scope,
|
|
921
|
-
* used to prevent duplicate proof submissions. Each user+scope combination
|
|
922
|
-
* produces a unique nullifier.
|
|
923
|
-
*
|
|
924
|
-
* @param publicInputs - Array of public input hex strings from proof response
|
|
925
|
-
* @param circuit - Circuit type to determine field positions
|
|
926
|
-
* @returns Nullifier as hex string (0x...), or null if inputs are insufficient
|
|
927
|
-
*
|
|
928
|
-
* @example
|
|
929
|
-
* ```typescript
|
|
930
|
-
* const result = await sdk.waitForProof(relay.requestId);
|
|
931
|
-
* if (result.status === 'completed') {
|
|
932
|
-
* const nullifier = sdk.extractNullifier(result.publicInputs, result.circuit);
|
|
933
|
-
* console.log('Nullifier:', nullifier);
|
|
934
|
-
* }
|
|
935
|
-
* ```
|
|
936
|
-
*/
|
|
937
|
-
extractNullifier(publicInputs: string[], circuit: CircuitType): string | null;
|
|
938
876
|
/**
|
|
939
877
|
* Extracts the scope from proof public inputs.
|
|
940
878
|
*
|
|
@@ -955,57 +893,5 @@ export declare class ProofportSDK {
|
|
|
955
893
|
* ```
|
|
956
894
|
*/
|
|
957
895
|
extractScope(publicInputs: string[], circuit: CircuitType): string | null;
|
|
958
|
-
/**
|
|
959
|
-
* Checks if a nullifier is already registered on-chain.
|
|
960
|
-
*
|
|
961
|
-
* Queries the ZKProofportNullifierRegistry contract to determine if the
|
|
962
|
-
* nullifier has been used before. Used to prevent duplicate proof submissions.
|
|
963
|
-
*
|
|
964
|
-
* Requires `nullifierRegistry` in SDK config.
|
|
965
|
-
*
|
|
966
|
-
* @param nullifier - Nullifier hex string from extractNullifier()
|
|
967
|
-
* @param provider - Optional ethers provider (defaults to public RPC for configured chain)
|
|
968
|
-
* @returns True if nullifier is already registered
|
|
969
|
-
* @throws Error if nullifierRegistry is not configured
|
|
970
|
-
*
|
|
971
|
-
* @example
|
|
972
|
-
* ```typescript
|
|
973
|
-
* const sdk = ProofportSDK.create({
|
|
974
|
-
* relayUrl: 'https://relay.zkproofport.app',
|
|
975
|
-
* nullifierRegistry: { address: '0x...', chainId: 8453 }
|
|
976
|
-
* });
|
|
977
|
-
*
|
|
978
|
-
* const nullifier = sdk.extractNullifier(publicInputs, circuit);
|
|
979
|
-
* const isDuplicate = await sdk.checkNullifier(nullifier);
|
|
980
|
-
* ```
|
|
981
|
-
*/
|
|
982
|
-
checkNullifier(nullifier: string, provider?: any): Promise<boolean>;
|
|
983
|
-
/**
|
|
984
|
-
* Gets detailed information about a registered nullifier from on-chain registry.
|
|
985
|
-
*
|
|
986
|
-
* Retrieves the registration timestamp, scope, and circuit ID for a nullifier.
|
|
987
|
-
* Returns null if the nullifier is not registered.
|
|
988
|
-
*
|
|
989
|
-
* Requires `nullifierRegistry` in SDK config.
|
|
990
|
-
*
|
|
991
|
-
* @param nullifier - Nullifier hex string from extractNullifier()
|
|
992
|
-
* @param provider - Optional ethers provider (defaults to public RPC for configured chain)
|
|
993
|
-
* @returns Nullifier info or null if not registered
|
|
994
|
-
* @throws Error if nullifierRegistry is not configured
|
|
995
|
-
*
|
|
996
|
-
* @example
|
|
997
|
-
* ```typescript
|
|
998
|
-
* const info = await sdk.getNullifierDetails(nullifier);
|
|
999
|
-
* if (info) {
|
|
1000
|
-
* console.log('Registered at:', new Date(info.registeredAt * 1000));
|
|
1001
|
-
* console.log('Circuit:', info.circuitId);
|
|
1002
|
-
* }
|
|
1003
|
-
* ```
|
|
1004
|
-
*/
|
|
1005
|
-
getNullifierDetails(nullifier: string, provider?: any): Promise<{
|
|
1006
|
-
registeredAt: number;
|
|
1007
|
-
scope: string;
|
|
1008
|
-
circuitId: string;
|
|
1009
|
-
} | null>;
|
|
1010
896
|
}
|
|
1011
897
|
export default ProofportSDK;
|
package/dist/constants.d.ts
CHANGED
|
@@ -128,7 +128,6 @@ export declare const MAX_QR_DATA_SIZE = 2953;
|
|
|
128
128
|
* - signal_hash: bytes 0-31
|
|
129
129
|
* - merkle_root: bytes 32-63
|
|
130
130
|
* - scope: bytes 64-95
|
|
131
|
-
* - nullifier: bytes 96-127
|
|
132
131
|
*
|
|
133
132
|
* @example
|
|
134
133
|
* ```typescript
|
|
@@ -146,8 +145,6 @@ export declare const COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT: {
|
|
|
146
145
|
readonly MERKLE_ROOT_END: 63;
|
|
147
146
|
readonly SCOPE_START: 64;
|
|
148
147
|
readonly SCOPE_END: 95;
|
|
149
|
-
readonly NULLIFIER_START: 96;
|
|
150
|
-
readonly NULLIFIER_END: 127;
|
|
151
148
|
};
|
|
152
149
|
/**
|
|
153
150
|
* Coinbase Country Attestation circuit public input layout (byte offsets).
|
|
@@ -160,7 +157,6 @@ export declare const COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT: {
|
|
|
160
157
|
* - country_list_length: byte 84
|
|
161
158
|
* - is_included: byte 85
|
|
162
159
|
* - scope: bytes 86-117
|
|
163
|
-
* - nullifier: bytes 118-149
|
|
164
160
|
*
|
|
165
161
|
* @example
|
|
166
162
|
* ```typescript
|
|
@@ -182,42 +178,4 @@ export declare const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT: {
|
|
|
182
178
|
readonly IS_INCLUDED: 85;
|
|
183
179
|
readonly SCOPE_START: 86;
|
|
184
180
|
readonly SCOPE_END: 117;
|
|
185
|
-
readonly NULLIFIER_START: 118;
|
|
186
|
-
readonly NULLIFIER_END: 149;
|
|
187
181
|
};
|
|
188
|
-
/**
|
|
189
|
-
* V1 NullifierRegistry contract ABI (DEPRECATED).
|
|
190
|
-
*
|
|
191
|
-
* This is the legacy nullifier registry interface.
|
|
192
|
-
* Use ZKPROOFPORT_NULLIFIER_REGISTRY_ABI for new integrations.
|
|
193
|
-
*
|
|
194
|
-
* @deprecated Use ZKPROOFPORT_NULLIFIER_REGISTRY_ABI instead. This is the V1 NullifierRegistry ABI.
|
|
195
|
-
*/
|
|
196
|
-
export declare const NULLIFIER_REGISTRY_ABI: string[];
|
|
197
|
-
/**
|
|
198
|
-
* ZKProofportNullifierRegistry contract ABI (V2).
|
|
199
|
-
*
|
|
200
|
-
* This is the current nullifier registry interface with relayer-only registration.
|
|
201
|
-
* Public view functions allow checking nullifier status and verifying proofs without registration.
|
|
202
|
-
*
|
|
203
|
-
* Key functions:
|
|
204
|
-
* - `isNullifierRegistered`: Check if a nullifier has been used
|
|
205
|
-
* - `getNullifierInfo`: Get registration details for a nullifier
|
|
206
|
-
* - `verifyOnly`: Verify a proof without registering the nullifier
|
|
207
|
-
*
|
|
208
|
-
* Note: Registration functions (verifyAndRegister) are relayer-only and not exposed in this ABI.
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* import { Contract } from 'ethers';
|
|
213
|
-
*
|
|
214
|
-
* const registry = new Contract(
|
|
215
|
-
* registryAddress,
|
|
216
|
-
* ZKPROOFPORT_NULLIFIER_REGISTRY_ABI,
|
|
217
|
-
* provider
|
|
218
|
-
* );
|
|
219
|
-
*
|
|
220
|
-
* const isUsed = await registry.isNullifierRegistered(nullifier);
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
223
|
-
export declare const ZKPROOFPORT_NULLIFIER_REGISTRY_ABI: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* // Initialize with environment preset
|
|
11
11
|
* const sdk = ProofportSDK.create('production');
|
|
12
12
|
*
|
|
13
|
-
* //
|
|
14
|
-
*
|
|
13
|
+
* // Set wallet signer
|
|
14
|
+
* sdk.setSigner(signer);
|
|
15
15
|
*
|
|
16
16
|
* // Create proof request via relay
|
|
17
17
|
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export { ProofportSDK, default } from './ProofportSDK';
|
|
29
|
-
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig,
|
|
29
|
+
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult, SDKEnvironment, } from './types';
|