@zkproofport-ai/sdk 0.2.5 → 0.2.7
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 +28 -201
- package/dist/constants.d.ts +0 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -4
- package/dist/constants.js.map +1 -1
- package/dist/flow.d.ts +5 -6
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +11 -33
- package/dist/flow.js.map +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/prove.d.ts +2 -6
- package/dist/prove.d.ts.map +1 -1
- package/dist/prove.js +3 -7
- package/dist/prove.js.map +1 -1
- package/dist/session.d.ts +2 -2
- package/dist/session.js +2 -2
- package/dist/types.d.ts +0 -30
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cdp.d.ts +0 -142
- package/dist/cdp.d.ts.map +0 -1
- package/dist/cdp.js +0 -78
- package/dist/cdp.js.map +0 -1
- package/dist/payment.d.ts +0 -17
- package/dist/payment.d.ts.map +0 -1
- package/dist/payment.js +0 -121
- package/dist/payment.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Client SDK for ZKProofport zero-knowledge proof generation on Base Mainnet.
|
|
|
6
6
|
|
|
7
7
|
@zkproofport-ai/sdk is a TypeScript SDK for generating privacy-preserving zero-knowledge proofs using Coinbase KYC attestations and OIDC JWT tokens. Generate a proof with a single function call, or fine-tune each step for custom workflows.
|
|
8
8
|
|
|
9
|
-
Proofs are generated in trusted execution environments (Nitro Enclaves) with cryptographic attestation.
|
|
9
|
+
Proofs are generated in trusted execution environments (Nitro Enclaves) with cryptographic attestation. Proof generation is **free** — no payment required.
|
|
10
10
|
|
|
11
11
|
## E2E Encryption (TEE Blind Relay)
|
|
12
12
|
|
|
@@ -14,8 +14,8 @@ All proof inputs are **end-to-end encrypted** using X25519 ECDH + AES-256-GCM. T
|
|
|
14
14
|
|
|
15
15
|
**How it works:**
|
|
16
16
|
|
|
17
|
-
1. `generateProof()`
|
|
18
|
-
2. The
|
|
17
|
+
1. `generateProof()` contacts the server to obtain the TEE public key
|
|
18
|
+
2. The response includes `teePublicKey` — the TEE's attested X25519 public key (cryptographically bound to the Nitro Enclave via COSE Sign1 attestation)
|
|
19
19
|
3. The SDK generates an ephemeral X25519 keypair, performs ECDH key agreement, and encrypts all circuit inputs with AES-256-GCM
|
|
20
20
|
4. The encrypted payload is sent to the server, which relays it blindly to the TEE
|
|
21
21
|
5. The TEE decrypts, generates the ZK proof, and returns it
|
|
@@ -33,110 +33,25 @@ npm install @zkproofport-ai/sdk ethers
|
|
|
33
33
|
|
|
34
34
|
## Prerequisites
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
**For Coinbase circuits** (`coinbase_kyc`, `coinbase_country`):
|
|
37
37
|
|
|
38
38
|
1. **Coinbase account with KYC verification** — Complete identity verification on [Coinbase](https://www.coinbase.com/)
|
|
39
39
|
2. **Coinbase KYC EAS attestation on Base** — Obtain an attestation via [Coinbase Verifications](https://www.coinbase.com/onchain-verify). This creates an on-chain EAS attestation on Base linked to your wallet address.
|
|
40
|
-
3. **
|
|
41
|
-
4. **Attestation wallet private key** (required) — The private key of the wallet that holds the EAS attestation. This is always a raw private key because the attestation is tied to a specific address.
|
|
42
|
-
|
|
43
|
-
5. **Payment wallet** (recommended) — Separate wallet with USDC balance for proof payment. Choose one:
|
|
44
|
-
|
|
45
|
-
- **Same as attestation wallet (NOT recommended)** — No additional setup, but **defeats zero-knowledge privacy**.
|
|
46
|
-
> ⚠️ **Privacy risk:** Using the attestation wallet for payment exposes your KYC-verified wallet address on-chain in the payment transaction, **directly linking your real-world identity to on-chain activity**. This defeats the purpose of zero-knowledge proofs. Always use a separate payment wallet (private key or CDP) to preserve privacy.
|
|
47
|
-
- **Separate private key** — A different wallet with USDC balance.
|
|
48
|
-
- **CDP MPC wallet** — Coinbase Developer Platform managed wallet. Private keys never leave Coinbase's TEE. Get credentials at [CDP Portal](https://portal.cdp.coinbase.com). Requires additional install:
|
|
49
|
-
```bash
|
|
50
|
-
npm install @coinbase/cdp-sdk
|
|
51
|
-
```
|
|
52
|
-
| Credential | Required | Description |
|
|
53
|
-
|------------|----------|-------------|
|
|
54
|
-
| `CDP_API_KEY_ID` | Yes | CDP API key ID |
|
|
55
|
-
| `CDP_API_KEY_SECRET` | Yes | CDP API key secret |
|
|
56
|
-
| `CDP_WALLET_SECRET` | Yes | CDP wallet encryption secret |
|
|
57
|
-
| `CDP_WALLET_ADDRESS` | No | Existing wallet address (creates new if omitted) |
|
|
40
|
+
3. **Attestation wallet private key** (required) — The private key of the wallet that holds the EAS attestation. This is always a raw private key because the attestation is tied to a specific address.
|
|
58
41
|
|
|
59
|
-
|
|
42
|
+
**For OIDC circuits** (`oidc_domain`): No wallet or attestation needed — just a JWT `id_token` from your OIDC provider.
|
|
60
43
|
|
|
61
|
-
|
|
44
|
+
## Quick Start
|
|
62
45
|
|
|
63
46
|
```typescript
|
|
64
47
|
import { generateProof, createConfig, fromPrivateKey, verifyProof } from '@zkproofport-ai/sdk';
|
|
65
48
|
|
|
66
|
-
const config = createConfig();
|
|
67
|
-
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
68
|
-
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
69
|
-
|
|
70
|
-
const result = await generateProof(
|
|
71
|
-
config,
|
|
72
|
-
{ attestation: attestationSigner, payment: paymentSigner },
|
|
73
|
-
{ circuit: 'coinbase_kyc', scope: 'my-app' }
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const verification = await verifyProof(result);
|
|
77
|
-
console.log('Valid:', verification.valid);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### With CDP Payment Wallet
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
import { generateProof, createConfig, fromPrivateKey, fromExternalWallet, verifyProof } from '@zkproofport-ai/sdk';
|
|
84
|
-
import { CdpClient } from '@coinbase/cdp-sdk';
|
|
85
|
-
|
|
86
|
-
const config = createConfig();
|
|
87
|
-
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
88
|
-
|
|
89
|
-
// Create CDP MPC wallet (private keys never leave Coinbase's TEE)
|
|
90
|
-
const cdp = new CdpClient();
|
|
91
|
-
const account = await cdp.evm.getOrCreateAccount({ name: 'proofport-payment' });
|
|
92
|
-
|
|
93
|
-
const paymentSigner = fromExternalWallet({
|
|
94
|
-
getAddress: () => account.address!,
|
|
95
|
-
signMessage: async (msg) => {
|
|
96
|
-
const message = msg instanceof Uint8Array ? Buffer.from(msg).toString() : msg;
|
|
97
|
-
const result = await cdp.evm.signMessage({ address: account.address!, message });
|
|
98
|
-
return result.signature;
|
|
99
|
-
},
|
|
100
|
-
signTypedData: async (domain, types, message) => {
|
|
101
|
-
const primaryType = Object.keys(types).find(k => k !== 'EIP712Domain') || '';
|
|
102
|
-
const result = await cdp.evm.signTypedData({ address: account.address!, domain, types, primaryType, message });
|
|
103
|
-
return result.signature;
|
|
104
|
-
},
|
|
105
|
-
sendTransaction: async (tx) => {
|
|
106
|
-
const result = await cdp.evm.sendTransaction({
|
|
107
|
-
address: account.address!, transaction: tx, network: 'base',
|
|
108
|
-
});
|
|
109
|
-
return { hash: result.transactionHash, wait: async () => ({ status: 1 }) };
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const result = await generateProof(
|
|
114
|
-
config,
|
|
115
|
-
{ attestation: attestationSigner, payment: paymentSigner },
|
|
116
|
-
{ circuit: 'coinbase_kyc', scope: 'my-app' }
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const verification = await verifyProof(result);
|
|
120
|
-
console.log('Valid:', verification.valid);
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### External Wallet Adapter
|
|
124
|
-
|
|
125
|
-
Wrap any external wallet (WalletConnect, MetaMask, etc.) using `fromExternalWallet()`:
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
import { generateProof, createConfig, fromPrivateKey, fromExternalWallet, verifyProof } from '@zkproofport-ai/sdk';
|
|
129
|
-
|
|
130
49
|
const config = createConfig();
|
|
131
50
|
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
132
51
|
|
|
133
|
-
// Wrap external wallet (e.g., from WalletConnect modal, Privy, etc.)
|
|
134
|
-
const externalWallet = await getWalletFromUI(); // Your wallet integration
|
|
135
|
-
const paymentSigner = fromExternalWallet(externalWallet);
|
|
136
|
-
|
|
137
52
|
const result = await generateProof(
|
|
138
53
|
config,
|
|
139
|
-
{ attestation: attestationSigner
|
|
54
|
+
{ attestation: attestationSigner },
|
|
140
55
|
{ circuit: 'coinbase_kyc', scope: 'my-app' }
|
|
141
56
|
);
|
|
142
57
|
|
|
@@ -149,15 +64,12 @@ console.log('Valid:', verification.valid);
|
|
|
149
64
|
```typescript
|
|
150
65
|
import { createConfig } from '@zkproofport-ai/sdk';
|
|
151
66
|
|
|
152
|
-
//
|
|
67
|
+
// Default — production use
|
|
153
68
|
const config = createConfig();
|
|
154
69
|
|
|
155
|
-
// Custom
|
|
70
|
+
// Custom server URL
|
|
156
71
|
const config = createConfig({
|
|
157
|
-
|
|
158
|
-
facilitatorHeaders: {
|
|
159
|
-
'Authorization': `Bearer ${process.env.CDP_FACILITATOR_TOKEN}`,
|
|
160
|
-
},
|
|
72
|
+
baseUrl: 'https://your-custom-server.example.com',
|
|
161
73
|
});
|
|
162
74
|
```
|
|
163
75
|
|
|
@@ -166,14 +78,12 @@ const config = createConfig({
|
|
|
166
78
|
| Field | Type | Default | Description |
|
|
167
79
|
|-------|------|---------|-------------|
|
|
168
80
|
| `baseUrl` | string | `https://ai.zkproofport.app` | proofport-ai server URL |
|
|
169
|
-
| `facilitatorUrl` | string | `https://x402.dexter.cash` | x402 payment facilitator URL |
|
|
170
|
-
| `facilitatorHeaders` | object | `{}` | Optional auth headers for custom facilitator (e.g., CDP with JWT) |
|
|
171
81
|
|
|
172
82
|
## Proof Generation
|
|
173
83
|
|
|
174
84
|
### Single-Step Flow
|
|
175
85
|
|
|
176
|
-
The `generateProof()` function handles the entire proof generation pipeline: signing, attestation fetching, circuit input preparation,
|
|
86
|
+
The `generateProof()` function handles the entire proof generation pipeline: signing, attestation fetching, circuit input preparation, and proof generation.
|
|
177
87
|
|
|
178
88
|
```typescript
|
|
179
89
|
import { generateProof, createConfig, fromPrivateKey } from '@zkproofport-ai/sdk';
|
|
@@ -181,14 +91,10 @@ import type { StepResult } from '@zkproofport-ai/sdk';
|
|
|
181
91
|
|
|
182
92
|
const config = createConfig();
|
|
183
93
|
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
184
|
-
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY); // optional
|
|
185
94
|
|
|
186
95
|
const result = await generateProof(
|
|
187
96
|
config,
|
|
188
|
-
{
|
|
189
|
-
attestation: attestationSigner,
|
|
190
|
-
payment: paymentSigner, // uses attestationSigner if not provided
|
|
191
|
-
},
|
|
97
|
+
{ attestation: attestationSigner },
|
|
192
98
|
{
|
|
193
99
|
circuit: 'coinbase_kyc',
|
|
194
100
|
scope: 'my-application',
|
|
@@ -206,7 +112,6 @@ const result = await generateProof(
|
|
|
206
112
|
console.log('Proof generated in', result.timing.totalMs, 'ms');
|
|
207
113
|
console.log('Proof:', result.proof);
|
|
208
114
|
console.log('Public inputs:', result.publicInputs);
|
|
209
|
-
console.log('Payment TX:', result.paymentTxHash);
|
|
210
115
|
|
|
211
116
|
// Attestation present if TEE mode enabled on server
|
|
212
117
|
if (result.attestation) {
|
|
@@ -219,11 +124,8 @@ if (result.attestation) {
|
|
|
219
124
|
1. Sign signal hash with attestation signer
|
|
220
125
|
2. Fetch Coinbase KYC attestation from EAS
|
|
221
126
|
3. Build circuit inputs (Merkle tree, hashes)
|
|
222
|
-
4.
|
|
223
|
-
5.
|
|
224
|
-
6. Sign EIP-3009 TransferWithAuthorization
|
|
225
|
-
7. Submit payment via x402 facilitator
|
|
226
|
-
8. Generate proof in TEE with payment proof (encrypted inputs if TEE enabled)
|
|
127
|
+
4. **Auto-detect E2E encryption** — if `teePublicKey` is present in server response, encrypt inputs with X25519 ECDH + AES-256-GCM
|
|
128
|
+
5. Generate proof in TEE (encrypted inputs if TEE enabled)
|
|
227
129
|
|
|
228
130
|
**Result fields:**
|
|
229
131
|
|
|
@@ -232,7 +134,6 @@ if (result.attestation) {
|
|
|
232
134
|
| `proof` | string | 0x-prefixed proof hex |
|
|
233
135
|
| `publicInputs` | string | 0x-prefixed public inputs hex |
|
|
234
136
|
| `proofWithInputs` | string | Combined proof + public inputs |
|
|
235
|
-
| `paymentTxHash` | string | Transaction hash of x402 payment |
|
|
236
137
|
| `attestation` | object | TEE attestation (document, proof_hash, verification) or null |
|
|
237
138
|
| `timing` | object | Execution times per step |
|
|
238
139
|
| `verification` | object | On-chain verifier info (chainId, address, rpcUrl) |
|
|
@@ -260,12 +161,9 @@ For advanced workflows or debugging, use individual step functions instead of `g
|
|
|
260
161
|
```typescript
|
|
261
162
|
import {
|
|
262
163
|
prepareInputs,
|
|
263
|
-
requestChallenge,
|
|
264
|
-
makePayment,
|
|
265
164
|
submitProof,
|
|
266
165
|
computeSignalHash,
|
|
267
166
|
CIRCUIT_NAME_MAP,
|
|
268
|
-
USDC_ADDRESSES,
|
|
269
167
|
EthersWalletSigner,
|
|
270
168
|
createConfig,
|
|
271
169
|
} from '@zkproofport-ai/sdk';
|
|
@@ -290,29 +188,10 @@ const inputs = await prepareInputs(config, {
|
|
|
290
188
|
scope,
|
|
291
189
|
});
|
|
292
190
|
|
|
293
|
-
// Step 3:
|
|
294
|
-
const challenge = await requestChallenge(config, circuit, inputs);
|
|
295
|
-
|
|
296
|
-
// Step 4: Make payment via x402 facilitator
|
|
297
|
-
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
|
|
298
|
-
const paymentWallet = new ethers.Wallet(process.env.PAYMENT_KEY, provider);
|
|
299
|
-
const paymentSigner = new EthersWalletSigner(paymentWallet);
|
|
300
|
-
|
|
301
|
-
const paymentTxHash = await makePayment(paymentSigner, {
|
|
302
|
-
nonce: challenge.nonce,
|
|
303
|
-
recipient: challenge.payment.payTo,
|
|
304
|
-
amount: parseInt(challenge.payment.maxAmountRequired),
|
|
305
|
-
asset: USDC_ADDRESSES['base'],
|
|
306
|
-
network: challenge.payment.network,
|
|
307
|
-
instruction: challenge.payment.description,
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
// Step 5: Submit proof with payment proof
|
|
191
|
+
// Step 3: Submit proof
|
|
311
192
|
const proofResponse = await submitProof(config, {
|
|
312
193
|
circuit,
|
|
313
194
|
inputs,
|
|
314
|
-
paymentTxHash,
|
|
315
|
-
paymentNonce: challenge.nonce,
|
|
316
195
|
});
|
|
317
196
|
|
|
318
197
|
console.log('Proof:', proofResponse.proof);
|
|
@@ -347,19 +226,18 @@ const result = await generateProof(config, signers, {
|
|
|
347
226
|
|
|
348
227
|
### OIDC Domain
|
|
349
228
|
|
|
350
|
-
Proves email domain affiliation using an OIDC JWT token (e.g., Google, Microsoft). No EAS attestation
|
|
229
|
+
Proves email domain affiliation using an OIDC JWT token (e.g., Google, Microsoft). No EAS attestation, Coinbase account, or wallet required — only a JWT `id_token`.
|
|
351
230
|
|
|
352
231
|
#### Google Workspace
|
|
353
232
|
|
|
354
233
|
```typescript
|
|
355
|
-
import { createConfig, generateProof
|
|
234
|
+
import { createConfig, generateProof } from '@zkproofport-ai/sdk';
|
|
356
235
|
|
|
357
236
|
const config = createConfig();
|
|
358
|
-
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
359
237
|
|
|
360
238
|
const result = await generateProof(
|
|
361
239
|
config,
|
|
362
|
-
{
|
|
240
|
+
{},
|
|
363
241
|
{
|
|
364
242
|
circuit: 'oidc_domain',
|
|
365
243
|
jwt: googleIdToken, // JWT id_token from Google OAuth
|
|
@@ -371,14 +249,13 @@ const result = await generateProof(
|
|
|
371
249
|
#### Microsoft 365
|
|
372
250
|
|
|
373
251
|
```typescript
|
|
374
|
-
import { createConfig, generateProof
|
|
252
|
+
import { createConfig, generateProof } from '@zkproofport-ai/sdk';
|
|
375
253
|
|
|
376
254
|
const config = createConfig();
|
|
377
|
-
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
378
255
|
|
|
379
256
|
const result = await generateProof(
|
|
380
257
|
config,
|
|
381
|
-
{
|
|
258
|
+
{},
|
|
382
259
|
{
|
|
383
260
|
circuit: 'oidc_domain',
|
|
384
261
|
jwt: microsoftIdToken, // JWT id_token from Microsoft OAuth
|
|
@@ -388,21 +265,20 @@ const result = await generateProof(
|
|
|
388
265
|
);
|
|
389
266
|
```
|
|
390
267
|
|
|
391
|
-
> **Note:** For OIDC circuits,
|
|
268
|
+
> **Note:** For OIDC circuits, no wallet or private key is needed — just a JWT `id_token` from your OIDC provider.
|
|
392
269
|
|
|
393
270
|
## Extracting Data from Proofs
|
|
394
271
|
|
|
395
272
|
For OIDC domain proofs, use helper functions to extract the domain and nullifier from public inputs:
|
|
396
273
|
|
|
397
274
|
```typescript
|
|
398
|
-
import { generateProof, createConfig,
|
|
275
|
+
import { generateProof, createConfig, extractDomainFromPublicInputs, extractNullifierFromPublicInputs } from '@zkproofport-ai/sdk';
|
|
399
276
|
|
|
400
277
|
const config = createConfig();
|
|
401
|
-
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
402
278
|
|
|
403
279
|
const result = await generateProof(
|
|
404
280
|
config,
|
|
405
|
-
{
|
|
281
|
+
{},
|
|
406
282
|
{
|
|
407
283
|
circuit: 'oidc_domain',
|
|
408
284
|
jwt: googleIdToken,
|
|
@@ -450,8 +326,6 @@ type CircuitId = 'coinbase_attestation' | 'coinbase_country_attestation' | 'oidc
|
|
|
450
326
|
```typescript
|
|
451
327
|
interface ClientConfig {
|
|
452
328
|
baseUrl: string;
|
|
453
|
-
facilitatorUrl?: string; // x402 facilitator URL (default: https://x402.dexter.cash)
|
|
454
|
-
facilitatorHeaders?: Record<string, string>; // Auth headers for custom facilitator
|
|
455
329
|
}
|
|
456
330
|
```
|
|
457
331
|
|
|
@@ -468,23 +342,8 @@ interface ProofportSigner {
|
|
|
468
342
|
// Create signer from ethers private key
|
|
469
343
|
function fromPrivateKey(key: string, provider?: ethers.Provider): ProofportSigner;
|
|
470
344
|
|
|
471
|
-
// Create signer from
|
|
472
|
-
|
|
473
|
-
constructor(wallet: {
|
|
474
|
-
getAddress(): string | Promise<string>;
|
|
475
|
-
signMessage(message: Uint8Array | string): Promise<string>;
|
|
476
|
-
signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{ name: string; type: string }>>, message: Record<string, unknown>): Promise<string>;
|
|
477
|
-
sendTransaction?(tx: { to: string; data: string; value?: bigint }): Promise<{ hash: string; wait(): Promise<{ status: number | null }> }>;
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// Wrap external wallet (WalletConnect, MetaMask, Privy, etc.)
|
|
482
|
-
function fromExternalWallet(wallet: {
|
|
483
|
-
getAddress(): string | Promise<string>;
|
|
484
|
-
signMessage(message: Uint8Array): Promise<string>;
|
|
485
|
-
signTypedData(domain: any, types: any, message: any): Promise<string>;
|
|
486
|
-
sendTransaction?(tx: any): Promise<{ hash: string; wait(): Promise<any> }>;
|
|
487
|
-
}): ProofportSigner;
|
|
345
|
+
// Create signer from ethers Wallet
|
|
346
|
+
function fromSigner(signer: ethers.Signer): ProofportSigner;
|
|
488
347
|
```
|
|
489
348
|
|
|
490
349
|
**Proof Parameters:**
|
|
@@ -507,7 +366,6 @@ interface ProofResult {
|
|
|
507
366
|
proof: string;
|
|
508
367
|
publicInputs: string;
|
|
509
368
|
proofWithInputs: string;
|
|
510
|
-
paymentTxHash: string;
|
|
511
369
|
attestation: {
|
|
512
370
|
document: string;
|
|
513
371
|
proof_hash: string;
|
|
@@ -520,7 +378,7 @@ interface ProofResult {
|
|
|
520
378
|
} | null;
|
|
521
379
|
timing: {
|
|
522
380
|
totalMs: number;
|
|
523
|
-
|
|
381
|
+
|
|
524
382
|
inputBuildMs?: number;
|
|
525
383
|
proveMs?: number;
|
|
526
384
|
};
|
|
@@ -556,33 +414,6 @@ interface StepResult {
|
|
|
556
414
|
}
|
|
557
415
|
```
|
|
558
416
|
|
|
559
|
-
## Payment
|
|
560
|
-
|
|
561
|
-
Payment is transparent to the application. When `generateProof()` runs, the user signs an EIP-3009 `TransferWithAuthorization` message (no gas cost). The signature is sent to the x402 facilitator, which completes the USDC transfer and proves payment to the server.
|
|
562
|
-
|
|
563
|
-
- Protocol: x402 (HTTP 402 Payment Required)
|
|
564
|
-
- Method: EIP-3009 `TransferWithAuthorization`
|
|
565
|
-
- Token: USDC on Base Mainnet
|
|
566
|
-
- Amount: $0.10 per proof
|
|
567
|
-
- Facilitator: `https://x402.dexter.cash` (default, pays gas)
|
|
568
|
-
- User cost: Only USDC, no ETH for gas
|
|
569
|
-
- Custom facilitator: Use `facilitatorUrl` + `facilitatorHeaders` in `ClientConfig` for alternative facilitators (e.g., CDP with JWT auth)
|
|
570
|
-
|
|
571
|
-
The payment transaction hash is included in `result.paymentTxHash` for settlement tracking.
|
|
572
|
-
|
|
573
|
-
### Custom Facilitator (CDP Example)
|
|
574
|
-
|
|
575
|
-
```typescript
|
|
576
|
-
const config = createConfig({
|
|
577
|
-
facilitatorUrl: 'https://cdp-facilitator.example.com',
|
|
578
|
-
facilitatorHeaders: {
|
|
579
|
-
'Authorization': `Bearer ${process.env.CDP_JWT_TOKEN}`,
|
|
580
|
-
},
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
const result = await generateProof(config, signers, params);
|
|
584
|
-
```
|
|
585
|
-
|
|
586
417
|
## Error Handling
|
|
587
418
|
|
|
588
419
|
```typescript
|
|
@@ -592,9 +423,7 @@ try {
|
|
|
592
423
|
const result = await generateProof(config, signers, params);
|
|
593
424
|
} catch (error) {
|
|
594
425
|
if (error instanceof Error) {
|
|
595
|
-
if (error.message.includes('
|
|
596
|
-
console.error('Payment required or payment failed');
|
|
597
|
-
} else if (error.message.includes('attestation')) {
|
|
426
|
+
if (error.message.includes('attestation')) {
|
|
598
427
|
console.error('Attestation not found or invalid');
|
|
599
428
|
} else if (error.message.includes('Sumcheck')) {
|
|
600
429
|
console.error('Proof verification failed on-chain');
|
|
@@ -610,9 +439,7 @@ Common errors:
|
|
|
610
439
|
| Error | Cause | Solution |
|
|
611
440
|
|-------|-------|----------|
|
|
612
441
|
| `Attestation not found` | Wallet has no Coinbase KYC attestation | Verify attestation on Base Mainnet via EAS |
|
|
613
|
-
| `402 Payment Required` | x402 payment failed or insufficient USDC | Ensure wallet has USDC balance, check x402 facilitator |
|
|
614
442
|
| `Sumcheck failed` | On-chain verification failed | Proof corrupted or verifier contract mismatch |
|
|
615
|
-
| `Transaction failed` | User rejected signature | Retry or check wallet |
|
|
616
443
|
|
|
617
444
|
## License
|
|
618
445
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -6,10 +6,6 @@ export declare const CIRCUITS: Record<string, {
|
|
|
6
6
|
}>;
|
|
7
7
|
export declare const COINBASE_ATTESTER_CONTRACT = "0x357458739F90461b99789350868CD7CF330Dd7EE";
|
|
8
8
|
export declare const AUTHORIZED_SIGNERS: string[];
|
|
9
|
-
export declare const USDC_ADDRESSES: {
|
|
10
|
-
readonly 'base-sepolia': "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
11
|
-
readonly base: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
12
|
-
};
|
|
13
9
|
export declare const DEFAULT_EAS_GRAPHQL = "https://base.easscan.org/graphql";
|
|
14
10
|
export declare const DEFAULT_EAS_RPC = "https://mainnet.base.org";
|
|
15
11
|
export declare const RAW_TX_PADDED_LENGTH = 300;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAeA,CAAC;AAEF,eAAO,MAAM,0BAA0B,+CAA+C,CAAC;AAEvF,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAeA,CAAC;AAEF,eAAO,MAAM,0BAA0B,+CAA+C,CAAC;AAEvF,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AACtE,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAE1D,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,uBAAuB,KAAK,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -21,10 +21,6 @@ export const AUTHORIZED_SIGNERS = [
|
|
|
21
21
|
'0x88fe64ea2e121f49bb77abea6c0a45e93638c3c5',
|
|
22
22
|
'0x44ace9abb148e8412ac4492e9a1ae6bd88226803',
|
|
23
23
|
];
|
|
24
|
-
export const USDC_ADDRESSES = {
|
|
25
|
-
'base-sepolia': '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
26
|
-
'base': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
27
|
-
};
|
|
28
24
|
export const DEFAULT_EAS_GRAPHQL = 'https://base.easscan.org/graphql';
|
|
29
25
|
export const DEFAULT_EAS_RPC = 'https://mainnet.base.org';
|
|
30
26
|
export const RAW_TX_PADDED_LENGTH = 300;
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAKhB;IACH,oBAAoB,EAAE;QACpB,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,4BAA4B,EAAE;QAC5B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,uBAAuB,EAAE;QACvB,WAAW,EAAE,aAAa;QAC1B,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,4CAA4C,CAAC;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAKhB;IACH,oBAAoB,EAAE;QACpB,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,4BAA4B,EAAE;QAC5B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,uBAAuB,EAAE;QACvB,WAAW,EAAE,aAAa;QAC1B,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,4CAA4C,CAAC;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
|
package/dist/flow.d.ts
CHANGED
|
@@ -4,21 +4,20 @@ export interface FlowCallbacks {
|
|
|
4
4
|
onStep?: (step: StepResult) => void;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Generate a ZK proof end-to-end
|
|
7
|
+
* Generate a ZK proof end-to-end.
|
|
8
8
|
*
|
|
9
9
|
* Automatically detects E2E encryption: if the server returns a TEE public key
|
|
10
|
-
* in the
|
|
10
|
+
* in the challenge response (TEE mode = nitro), inputs are encrypted with
|
|
11
11
|
* the TEE's attested X25519 public key. Otherwise (TEE disabled), inputs are
|
|
12
12
|
* sent in plaintext.
|
|
13
13
|
*
|
|
14
|
-
* @param config - Server URL
|
|
15
|
-
* @param signers - ProofportSigner for attestation (required)
|
|
14
|
+
* @param config - Server URL
|
|
15
|
+
* @param signers - ProofportSigner for attestation (required)
|
|
16
16
|
* @param params - Circuit name, scope, and optional country params
|
|
17
17
|
* @param callbacks - Optional callbacks for step progress
|
|
18
|
-
* @returns ProofResult with proof, publicInputs,
|
|
18
|
+
* @returns ProofResult with proof, publicInputs, and attestation info
|
|
19
19
|
*/
|
|
20
20
|
export declare function generateProof(config: ClientConfig, signers: {
|
|
21
21
|
attestation: ProofportSigner;
|
|
22
|
-
payment?: ProofportSigner;
|
|
23
22
|
}, params: ProofParams, callbacks?: FlowCallbacks): Promise<ProofResult>;
|
|
24
23
|
//# sourceMappingURL=flow.d.ts.map
|
package/dist/flow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,UAAU,
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,UAAU,EACX,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,EACzC,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,WAAW,CAAC,CAgGtB"}
|
package/dist/flow.js
CHANGED
|
@@ -3,28 +3,26 @@ import { CIRCUIT_NAME_MAP } from './types.js';
|
|
|
3
3
|
import { requestChallenge } from './session.js';
|
|
4
4
|
import { prepareInputs, computeSignalHash } from './inputs.js';
|
|
5
5
|
import { prepareOidcPayload } from './oidc-inputs.js';
|
|
6
|
-
import { makePayment } from './payment.js';
|
|
7
6
|
import { submitProof, submitEncryptedProof } from './prove.js';
|
|
8
|
-
import { CIRCUITS
|
|
7
|
+
import { CIRCUITS } from './constants.js';
|
|
9
8
|
import { encryptForTee } from './tee.js';
|
|
10
9
|
/**
|
|
11
|
-
* Generate a ZK proof end-to-end
|
|
10
|
+
* Generate a ZK proof end-to-end.
|
|
12
11
|
*
|
|
13
12
|
* Automatically detects E2E encryption: if the server returns a TEE public key
|
|
14
|
-
* in the
|
|
13
|
+
* in the challenge response (TEE mode = nitro), inputs are encrypted with
|
|
15
14
|
* the TEE's attested X25519 public key. Otherwise (TEE disabled), inputs are
|
|
16
15
|
* sent in plaintext.
|
|
17
16
|
*
|
|
18
|
-
* @param config - Server URL
|
|
19
|
-
* @param signers - ProofportSigner for attestation (required)
|
|
17
|
+
* @param config - Server URL
|
|
18
|
+
* @param signers - ProofportSigner for attestation (required)
|
|
20
19
|
* @param params - Circuit name, scope, and optional country params
|
|
21
20
|
* @param callbacks - Optional callbacks for step progress
|
|
22
|
-
* @returns ProofResult with proof, publicInputs,
|
|
21
|
+
* @returns ProofResult with proof, publicInputs, and attestation info
|
|
23
22
|
*/
|
|
24
23
|
export async function generateProof(config, signers, params, callbacks) {
|
|
25
24
|
const circuitId = CIRCUIT_NAME_MAP[params.circuit];
|
|
26
25
|
const scope = params.scope || 'proofport';
|
|
27
|
-
const paymentSigner = signers.payment || signers.attestation;
|
|
28
26
|
const isOidc = CIRCUITS[circuitId]?.inputType === 'oidc';
|
|
29
27
|
const steps = [];
|
|
30
28
|
function recordStep(step, name, data, startTime) {
|
|
@@ -67,25 +65,12 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
67
65
|
oidcPayload = await prepareOidcPayload({ jwt: params.jwt, scope, provider: params.provider });
|
|
68
66
|
recordStep(2, 'Prepare Inputs (OIDC)', { payloadFields: Object.keys(oidcPayload).length }, t2);
|
|
69
67
|
}
|
|
70
|
-
// Step 3: Request
|
|
68
|
+
// Step 3: Request challenge (server returns nonce + TEE key if available)
|
|
71
69
|
let t = Date.now();
|
|
72
70
|
const challenge = await requestChallenge(config, params.circuit);
|
|
73
71
|
const isE2E = !!challenge.teePublicKey;
|
|
74
72
|
recordStep(3, 'Request Challenge', { nonce: challenge.nonce, e2e: isE2E, keyId: challenge.teePublicKey?.keyId ?? null }, t);
|
|
75
|
-
// Step 4:
|
|
76
|
-
t = Date.now();
|
|
77
|
-
const network = challenge.payment.network;
|
|
78
|
-
const paymentInfo = {
|
|
79
|
-
nonce: challenge.nonce,
|
|
80
|
-
recipient: challenge.payment.payTo,
|
|
81
|
-
amount: parseInt(challenge.payment.maxAmountRequired),
|
|
82
|
-
asset: USDC_ADDRESSES[network],
|
|
83
|
-
network: challenge.payment.network,
|
|
84
|
-
instruction: challenge.payment.description,
|
|
85
|
-
};
|
|
86
|
-
const paymentTxHash = await makePayment(paymentSigner, paymentInfo, config.facilitatorUrl || challenge.facilitatorUrl, config.facilitatorHeaders);
|
|
87
|
-
recordStep(4, 'Make Payment', { txHash: paymentTxHash }, t);
|
|
88
|
-
// Step 5: Submit proof (encrypted or plaintext based on TEE availability)
|
|
73
|
+
// Step 4: Submit proof (encrypted or plaintext based on TEE availability)
|
|
89
74
|
t = Date.now();
|
|
90
75
|
let proveResponse;
|
|
91
76
|
if (isE2E) {
|
|
@@ -95,36 +80,29 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
95
80
|
proveResponse = await submitEncryptedProof(config, {
|
|
96
81
|
circuit: params.circuit,
|
|
97
82
|
encryptedPayload,
|
|
98
|
-
paymentTxHash,
|
|
99
|
-
paymentNonce: challenge.nonce,
|
|
100
83
|
});
|
|
101
|
-
recordStep(
|
|
84
|
+
recordStep(4, 'Generate Proof (E2E Encrypted)', proveResponse, t);
|
|
102
85
|
}
|
|
103
86
|
else if (isOidc) {
|
|
104
87
|
// OIDC plaintext path: send payload (JWT + JWKS) — server relays to prover, prover validates + builds inputs
|
|
105
88
|
proveResponse = await submitProof(config, {
|
|
106
89
|
circuit: params.circuit,
|
|
107
90
|
inputs: oidcPayload,
|
|
108
|
-
paymentTxHash,
|
|
109
|
-
paymentNonce: challenge.nonce,
|
|
110
91
|
});
|
|
111
|
-
recordStep(
|
|
92
|
+
recordStep(4, 'Generate Proof (OIDC)', proveResponse, t);
|
|
112
93
|
}
|
|
113
94
|
else {
|
|
114
95
|
// Coinbase plaintext path: send pre-computed inputs (TEE disabled / local dev)
|
|
115
96
|
proveResponse = await submitProof(config, {
|
|
116
97
|
circuit: params.circuit,
|
|
117
98
|
inputs: easInputs,
|
|
118
|
-
paymentTxHash,
|
|
119
|
-
paymentNonce: challenge.nonce,
|
|
120
99
|
});
|
|
121
|
-
recordStep(
|
|
100
|
+
recordStep(4, 'Generate Proof', proveResponse, t);
|
|
122
101
|
}
|
|
123
102
|
return {
|
|
124
103
|
proof: proveResponse.proof,
|
|
125
104
|
publicInputs: proveResponse.publicInputs,
|
|
126
105
|
proofWithInputs: proveResponse.proofWithInputs,
|
|
127
|
-
paymentTxHash,
|
|
128
106
|
attestation: proveResponse.attestation,
|
|
129
107
|
timing: proveResponse.timing,
|
|
130
108
|
verification: proveResponse.verification,
|
package/dist/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACj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AAC;QACH,UAAU,CAAC,CAAC,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,YAAY,EAAE,aAAa,CAAC,YAAY;KACzC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export type { ClientConfig, CircuitName, CircuitId,
|
|
1
|
+
export type { ClientConfig, CircuitName, CircuitId, ChallengeResponse, ProveInputs, ProveRequest, ProveResponse, VerifyResult, EASAttestation, AttestationData, ProofParams, ProofResult, StepResult, } from './types.js';
|
|
2
2
|
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
3
|
-
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS,
|
|
3
|
+
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, } from './constants.js';
|
|
4
4
|
export { createConfig } from './config.js';
|
|
5
5
|
export { generateProof } from './flow.js';
|
|
6
6
|
export type { FlowCallbacks } from './flow.js';
|
|
7
7
|
export { requestChallenge, createSession } from './session.js';
|
|
8
|
-
export { makePayment } from './payment.js';
|
|
9
8
|
export { submitProof, submitEncryptedProof } from './prove.js';
|
|
10
9
|
export { verifyProof } from './verify.js';
|
|
11
10
|
export { prepareInputs, computeSignalHash, computeScope, computeNullifier, } from './inputs.js';
|
|
@@ -13,8 +12,6 @@ export { prepareOidcInputs, prepareOidcPayload } from './oidc-inputs.js';
|
|
|
13
12
|
export type { OidcCircuitInputs, OidcProvePayload, PrepareOidcParams } from './oidc-inputs.js';
|
|
14
13
|
export type { ProofportSigner } from './signer.js';
|
|
15
14
|
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
16
|
-
export { CdpWalletSigner, fromExternalWallet } from './cdp.js';
|
|
17
|
-
export type { ExternalWallet } from './cdp.js';
|
|
18
15
|
export { extractDomainFromPublicInputs, extractScopeFromPublicInputs, extractNullifierFromPublicInputs, } from './extract.js';
|
|
19
16
|
export { fetchAttestation, getSignerAddress, } from './attestation.js';
|
|
20
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG9D,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG/F,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGnF,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
2
2
|
// Constants
|
|
3
|
-
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS,
|
|
3
|
+
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, } from './constants.js';
|
|
4
4
|
// Configuration
|
|
5
5
|
export { createConfig } from './config.js';
|
|
6
6
|
// Flow (main entry point)
|
|
7
7
|
export { generateProof } from './flow.js';
|
|
8
8
|
// Individual steps (for step-by-step usage)
|
|
9
9
|
export { requestChallenge, createSession } from './session.js';
|
|
10
|
-
export { makePayment } from './payment.js';
|
|
11
10
|
export { submitProof, submitEncryptedProof } from './prove.js';
|
|
12
11
|
export { verifyProof } from './verify.js';
|
|
13
12
|
// Input computation (customer-facing helpers)
|
|
@@ -15,8 +14,6 @@ export { prepareInputs, computeSignalHash, computeScope, computeNullifier, } fro
|
|
|
15
14
|
// OIDC: SDK fetches JWKS, TEE validates JWT + builds circuit inputs
|
|
16
15
|
export { prepareOidcInputs, prepareOidcPayload } from './oidc-inputs.js';
|
|
17
16
|
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
18
|
-
// CDP (Coinbase Developer Platform) signer
|
|
19
|
-
export { CdpWalletSigner, fromExternalWallet } from './cdp.js';
|
|
20
17
|
// Extraction helpers (parse publicInputs from proof results)
|
|
21
18
|
export { extractDomainFromPublicInputs, extractScopeFromPublicInputs, extractNullifierFromPublicInputs, } from './extract.js';
|
|
22
19
|
// Attestation (customer-facing helpers)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9D,YAAY;AACZ,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,4CAA4C;AAC5C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,8CAA8C;AAC9C,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,oEAAoE;AACpE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKzE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnF,6DAA6D;AAC7D,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,cAAc,CAAC;AAEtB,wCAAwC;AACxC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/prove.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ClientConfig, CircuitName, ProveInputs, ProveResponse } from './types.js';
|
|
2
2
|
import type { EncryptedEnvelope } from './tee.js';
|
|
3
3
|
/**
|
|
4
|
-
* Submit proof generation
|
|
5
|
-
* POST /api/v1/prove
|
|
4
|
+
* Submit proof generation request.
|
|
5
|
+
* POST /api/v1/prove
|
|
6
6
|
*
|
|
7
7
|
* The `inputs` field accepts either:
|
|
8
8
|
* - `ProveInputs` (EAS coinbase path)
|
|
@@ -11,8 +11,6 @@ import type { EncryptedEnvelope } from './tee.js';
|
|
|
11
11
|
export declare function submitProof(config: ClientConfig, request: {
|
|
12
12
|
circuit: CircuitName;
|
|
13
13
|
inputs?: ProveInputs | Record<string, unknown>;
|
|
14
|
-
paymentTxHash: string;
|
|
15
|
-
paymentNonce: string;
|
|
16
14
|
}): Promise<ProveResponse>;
|
|
17
15
|
/**
|
|
18
16
|
* Submit an E2E encrypted proof request.
|
|
@@ -21,7 +19,5 @@ export declare function submitProof(config: ClientConfig, request: {
|
|
|
21
19
|
export declare function submitEncryptedProof(config: ClientConfig, request: {
|
|
22
20
|
circuit: CircuitName;
|
|
23
21
|
encryptedPayload: EncryptedEnvelope;
|
|
24
|
-
paymentTxHash: string;
|
|
25
|
-
paymentNonce: string;
|
|
26
22
|
}): Promise<ProveResponse>;
|
|
27
23
|
//# sourceMappingURL=prove.d.ts.map
|
package/dist/prove.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD,GACA,OAAO,CAAC,aAAa,CAAC,CAoBxB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,gBAAgB,EAAE,iBAAiB,CAAC;CACrC,GACA,OAAO,CAAC,aAAa,CAAC,CAwBxB"}
|
package/dist/prove.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Submit proof generation
|
|
3
|
-
* POST /api/v1/prove
|
|
2
|
+
* Submit proof generation request.
|
|
3
|
+
* POST /api/v1/prove
|
|
4
4
|
*
|
|
5
5
|
* The `inputs` field accepts either:
|
|
6
6
|
* - `ProveInputs` (EAS coinbase path)
|
|
@@ -16,8 +16,6 @@ export async function submitProof(config, request) {
|
|
|
16
16
|
method: 'POST',
|
|
17
17
|
headers: {
|
|
18
18
|
'Content-Type': 'application/json',
|
|
19
|
-
'X-Payment-TX': request.paymentTxHash,
|
|
20
|
-
'X-Payment-Nonce': request.paymentNonce,
|
|
21
19
|
},
|
|
22
20
|
body: JSON.stringify(body),
|
|
23
21
|
});
|
|
@@ -37,8 +35,6 @@ export async function submitEncryptedProof(config, request) {
|
|
|
37
35
|
method: 'POST',
|
|
38
36
|
headers: {
|
|
39
37
|
'Content-Type': 'application/json',
|
|
40
|
-
'X-Payment-TX': request.paymentTxHash,
|
|
41
|
-
'X-Payment-Nonce': request.paymentNonce,
|
|
42
38
|
},
|
|
43
39
|
body: JSON.stringify({
|
|
44
40
|
circuit: request.circuit,
|
|
@@ -48,7 +44,7 @@ export async function submitEncryptedProof(config, request) {
|
|
|
48
44
|
if (!response.ok) {
|
|
49
45
|
const error = await response.json().catch(() => ({ message: `HTTP ${response.status}` }));
|
|
50
46
|
if (response.status === 409) {
|
|
51
|
-
throw new Error('TEE key rotated. Retry with a new
|
|
47
|
+
throw new Error('TEE key rotated. Retry with a new challenge to get the updated key.');
|
|
52
48
|
}
|
|
53
49
|
throw new Error(`Proof generation failed: ${JSON.stringify(error)}`);
|
|
54
50
|
}
|
package/dist/prove.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAoB,EACpB,OAGC;IAED,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC;IAC7C,MAAM,IAAI,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EA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AC,CAAC,CAAC;QAE1F,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAA4B,CAAC;AACnD,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClientConfig, CircuitName, ChallengeResponse, ProveInputs } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Request a
|
|
4
|
-
* POST /api/v1/prove without
|
|
3
|
+
* Request a challenge from the server.
|
|
4
|
+
* POST /api/v1/prove without proof headers → server returns nonce + TEE key info.
|
|
5
5
|
*/
|
|
6
6
|
export declare function requestChallenge(config: ClientConfig, circuit: CircuitName, inputs?: ProveInputs): Promise<ChallengeResponse>;
|
|
7
7
|
export { requestChallenge as createSession };
|
package/dist/session.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Request a
|
|
3
|
-
* POST /api/v1/prove without
|
|
2
|
+
* Request a challenge from the server.
|
|
3
|
+
* POST /api/v1/prove without proof headers → server returns nonce + TEE key info.
|
|
4
4
|
*/
|
|
5
5
|
export async function requestChallenge(config, circuit, inputs) {
|
|
6
6
|
const url = `${config.baseUrl}/api/v1/prove`;
|
package/dist/types.d.ts
CHANGED
|
@@ -9,39 +9,11 @@ export declare const CIRCUIT_ID_MAP: Record<CircuitId, CircuitName>;
|
|
|
9
9
|
export interface ClientConfig {
|
|
10
10
|
/** proofport-ai server URL (e.g. https://stg-ai.zkproofport.app) */
|
|
11
11
|
baseUrl: string;
|
|
12
|
-
/** x402 facilitator URL for payment settlement */
|
|
13
|
-
facilitatorUrl?: string;
|
|
14
|
-
/** Optional headers for facilitator auth (e.g., CDP Bearer token) */
|
|
15
|
-
facilitatorHeaders?: Record<string, string>;
|
|
16
|
-
}
|
|
17
|
-
export interface PaymentInfo {
|
|
18
|
-
nonce: string;
|
|
19
|
-
recipient: string;
|
|
20
|
-
amount: number;
|
|
21
|
-
asset: string;
|
|
22
|
-
network: string;
|
|
23
|
-
instruction: string;
|
|
24
|
-
}
|
|
25
|
-
export interface PaymentRequirements {
|
|
26
|
-
scheme: string;
|
|
27
|
-
network: string;
|
|
28
|
-
maxAmountRequired: string;
|
|
29
|
-
resource: string;
|
|
30
|
-
description: string;
|
|
31
|
-
mimeType: string;
|
|
32
|
-
payTo: string;
|
|
33
|
-
extra: {
|
|
34
|
-
name: string;
|
|
35
|
-
version: string;
|
|
36
|
-
nonce: string;
|
|
37
|
-
};
|
|
38
12
|
}
|
|
39
13
|
export interface ChallengeResponse {
|
|
40
14
|
error: string;
|
|
41
15
|
message: string;
|
|
42
16
|
nonce: string;
|
|
43
|
-
payment: PaymentRequirements;
|
|
44
|
-
facilitatorUrl?: string;
|
|
45
17
|
teePublicKey?: {
|
|
46
18
|
publicKey: string;
|
|
47
19
|
keyId: string;
|
|
@@ -97,7 +69,6 @@ export interface ProveResponse {
|
|
|
97
69
|
} | null;
|
|
98
70
|
timing: {
|
|
99
71
|
totalMs: number;
|
|
100
|
-
paymentVerifyMs?: number;
|
|
101
72
|
inputBuildMs?: number;
|
|
102
73
|
proveMs?: number;
|
|
103
74
|
};
|
|
@@ -142,7 +113,6 @@ export interface ProofResult {
|
|
|
142
113
|
proof: string;
|
|
143
114
|
publicInputs: string;
|
|
144
115
|
proofWithInputs: string;
|
|
145
|
-
paymentTxHash: string;
|
|
146
116
|
attestation: ProveResponse['attestation'];
|
|
147
117
|
timing: ProveResponse['timing'];
|
|
148
118
|
verification: ProveResponse['verification'];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"m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ACd,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CAC7C;AAID,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
package/dist/cdp.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { ProofportSigner } from './signer.js';
|
|
2
|
-
/**
|
|
3
|
-
* Adapter interface for CDP wallet-like objects (or any external wallet).
|
|
4
|
-
*
|
|
5
|
-
* Pass any object that satisfies these method signatures — CDP MPC wallets,
|
|
6
|
-
* viem wallets, Privy embedded wallets, etc. — and wrap it with
|
|
7
|
-
* `CdpWalletSigner` or `fromExternalWallet()` to get a `ProofportSigner`.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // With @coinbase/cdp-sdk
|
|
12
|
-
* import { CdpClient } from '@coinbase/cdp-sdk';
|
|
13
|
-
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
14
|
-
*
|
|
15
|
-
* const cdp = new CdpClient();
|
|
16
|
-
* const wallet = await cdp.evm.getOrCreateWallet({ networkId: 'base' });
|
|
17
|
-
* const account = await wallet.getDefaultAddress();
|
|
18
|
-
*
|
|
19
|
-
* const signer = new CdpWalletSigner({
|
|
20
|
-
* getAddress: () => account.getId(),
|
|
21
|
-
* signMessage: (msg) => account.signPayload({ payload: Buffer.from(msg).toString('hex') }).then(r => r.signature),
|
|
22
|
-
* signTypedData: (domain, types, message) => account.signTypedData({ domain, types, message }),
|
|
23
|
-
* sendTransaction: async (tx) => {
|
|
24
|
-
* const result = await account.sendTransaction(tx);
|
|
25
|
-
* return { hash: result.transactionHash, wait: async () => ({ status: 1 }) };
|
|
26
|
-
* },
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export interface ExternalWallet {
|
|
31
|
-
/**
|
|
32
|
-
* Returns the wallet's Ethereum address.
|
|
33
|
-
* May be synchronous or asynchronous depending on the provider.
|
|
34
|
-
*/
|
|
35
|
-
getAddress(): string | Promise<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Signs a raw message (personal_sign style).
|
|
38
|
-
* Accepts either a Uint8Array of raw bytes or a pre-encoded string.
|
|
39
|
-
*/
|
|
40
|
-
signMessage(message: Uint8Array | string): Promise<string>;
|
|
41
|
-
/**
|
|
42
|
-
* Signs EIP-712 typed data.
|
|
43
|
-
* Compatible with ethers v6 `signTypedData` and viem `signTypedData` call shapes.
|
|
44
|
-
*/
|
|
45
|
-
signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{
|
|
46
|
-
name: string;
|
|
47
|
-
type: string;
|
|
48
|
-
}>>, message: Record<string, unknown>): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* Sends a transaction and returns the hash plus a `wait()` helper.
|
|
51
|
-
* Optional — omit if the wallet is used only for signing (e.g., attestation signer).
|
|
52
|
-
* If omitted and `sendTransaction` is called on the signer, an error is thrown at runtime.
|
|
53
|
-
*/
|
|
54
|
-
sendTransaction?(tx: {
|
|
55
|
-
to: string;
|
|
56
|
-
data: string;
|
|
57
|
-
value?: bigint;
|
|
58
|
-
}): Promise<{
|
|
59
|
-
hash: string;
|
|
60
|
-
wait(): Promise<{
|
|
61
|
-
status: number | null;
|
|
62
|
-
}>;
|
|
63
|
-
}>;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Adapter that bridges any `ExternalWallet`-compatible object to the
|
|
67
|
-
* `ProofportSigner` interface. No additional npm dependencies required —
|
|
68
|
-
* the caller brings their own wallet implementation.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
73
|
-
*
|
|
74
|
-
* // Wrap any CDP / external wallet
|
|
75
|
-
* const signer = new CdpWalletSigner(myExternalWallet);
|
|
76
|
-
*
|
|
77
|
-
* // Use as attestation signer
|
|
78
|
-
* const client = new ProofportClient({ ... }, { attestation: signer });
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare class CdpWalletSigner implements ProofportSigner {
|
|
82
|
-
private readonly wallet;
|
|
83
|
-
constructor(wallet: ExternalWallet);
|
|
84
|
-
/** Returns the wallet address, resolving async providers transparently. */
|
|
85
|
-
getAddress(): string | Promise<string>;
|
|
86
|
-
/**
|
|
87
|
-
* Signs a raw byte message.
|
|
88
|
-
* Passes the Uint8Array directly to the underlying wallet; the wallet is
|
|
89
|
-
* responsible for any encoding (e.g., personal_sign prefix).
|
|
90
|
-
*/
|
|
91
|
-
signMessage(message: Uint8Array): Promise<string>;
|
|
92
|
-
/**
|
|
93
|
-
* Signs EIP-712 typed data.
|
|
94
|
-
* The strict `ProofportSigner` domain shape is widened to
|
|
95
|
-
* `Record<string, unknown>` when forwarded so any external wallet
|
|
96
|
-
* implementation can accept it without type conflicts.
|
|
97
|
-
*/
|
|
98
|
-
signTypedData(domain: {
|
|
99
|
-
name: string;
|
|
100
|
-
version: string;
|
|
101
|
-
chainId: number;
|
|
102
|
-
verifyingContract: string;
|
|
103
|
-
}, types: Record<string, Array<{
|
|
104
|
-
name: string;
|
|
105
|
-
type: string;
|
|
106
|
-
}>>, message: Record<string, unknown>): Promise<string>;
|
|
107
|
-
/**
|
|
108
|
-
* Sends a transaction via the underlying wallet.
|
|
109
|
-
* Throws a descriptive error if the wrapped wallet did not provide
|
|
110
|
-
* a `sendTransaction` method (e.g., signing-only attestation wallets).
|
|
111
|
-
*/
|
|
112
|
-
sendTransaction(tx: {
|
|
113
|
-
to: string;
|
|
114
|
-
data: string;
|
|
115
|
-
value?: bigint;
|
|
116
|
-
}): Promise<{
|
|
117
|
-
hash: string;
|
|
118
|
-
wait(): Promise<{
|
|
119
|
-
status: number | null;
|
|
120
|
-
}>;
|
|
121
|
-
}>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Convenience factory — equivalent to `new CdpWalletSigner(wallet)`.
|
|
125
|
-
*
|
|
126
|
-
* Useful for returning a `ProofportSigner` without exposing the concrete
|
|
127
|
-
* `CdpWalletSigner` class to callers.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* import { fromExternalWallet } from '@zkproofport-ai/sdk';
|
|
132
|
-
*
|
|
133
|
-
* const signer = fromExternalWallet({
|
|
134
|
-
* getAddress: () => '0xYourAddress',
|
|
135
|
-
* signMessage: (msg) => myWallet.sign(msg),
|
|
136
|
-
* signTypedData: (domain, types, message) =>
|
|
137
|
-
* myWallet.signTypedData({ domain, types, message }),
|
|
138
|
-
* });
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export declare function fromExternalWallet(wallet: ExternalWallet): ProofportSigner;
|
|
142
|
-
//# sourceMappingURL=cdp.d.ts.map
|
package/dist/cdp.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3D;;;OAGG;IACH,aAAa,CACX,MAAM,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,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;OAIG;IACG,eAAe,CAAC,EAAE,EAAE;QACxB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,IAAI,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAU1E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAE1E"}
|
package/dist/cdp.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter that bridges any `ExternalWallet`-compatible object to the
|
|
3
|
-
* `ProofportSigner` interface. No additional npm dependencies required —
|
|
4
|
-
* the caller brings their own wallet implementation.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
9
|
-
*
|
|
10
|
-
* // Wrap any CDP / external wallet
|
|
11
|
-
* const signer = new CdpWalletSigner(myExternalWallet);
|
|
12
|
-
*
|
|
13
|
-
* // Use as attestation signer
|
|
14
|
-
* const client = new ProofportClient({ ... }, { attestation: signer });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class CdpWalletSigner {
|
|
18
|
-
wallet;
|
|
19
|
-
constructor(wallet) {
|
|
20
|
-
this.wallet = wallet;
|
|
21
|
-
}
|
|
22
|
-
/** Returns the wallet address, resolving async providers transparently. */
|
|
23
|
-
getAddress() {
|
|
24
|
-
return this.wallet.getAddress();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Signs a raw byte message.
|
|
28
|
-
* Passes the Uint8Array directly to the underlying wallet; the wallet is
|
|
29
|
-
* responsible for any encoding (e.g., personal_sign prefix).
|
|
30
|
-
*/
|
|
31
|
-
async signMessage(message) {
|
|
32
|
-
return this.wallet.signMessage(message);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Signs EIP-712 typed data.
|
|
36
|
-
* The strict `ProofportSigner` domain shape is widened to
|
|
37
|
-
* `Record<string, unknown>` when forwarded so any external wallet
|
|
38
|
-
* implementation can accept it without type conflicts.
|
|
39
|
-
*/
|
|
40
|
-
async signTypedData(domain, types, message) {
|
|
41
|
-
return this.wallet.signTypedData(domain, types, message);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Sends a transaction via the underlying wallet.
|
|
45
|
-
* Throws a descriptive error if the wrapped wallet did not provide
|
|
46
|
-
* a `sendTransaction` method (e.g., signing-only attestation wallets).
|
|
47
|
-
*/
|
|
48
|
-
async sendTransaction(tx) {
|
|
49
|
-
if (typeof this.wallet.sendTransaction !== 'function') {
|
|
50
|
-
throw new Error('CdpWalletSigner: the wrapped wallet does not implement sendTransaction. ' +
|
|
51
|
-
'Provide a sendTransaction method on the ExternalWallet object, or use a ' +
|
|
52
|
-
'different signer for payment transactions.');
|
|
53
|
-
}
|
|
54
|
-
return this.wallet.sendTransaction(tx);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Convenience factory — equivalent to `new CdpWalletSigner(wallet)`.
|
|
59
|
-
*
|
|
60
|
-
* Useful for returning a `ProofportSigner` without exposing the concrete
|
|
61
|
-
* `CdpWalletSigner` class to callers.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { fromExternalWallet } from '@zkproofport-ai/sdk';
|
|
66
|
-
*
|
|
67
|
-
* const signer = fromExternalWallet({
|
|
68
|
-
* getAddress: () => '0xYourAddress',
|
|
69
|
-
* signMessage: (msg) => myWallet.sign(msg),
|
|
70
|
-
* signTypedData: (domain, types, message) =>
|
|
71
|
-
* myWallet.signTypedData({ domain, types, message }),
|
|
72
|
-
* });
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export function fromExternalWallet(wallet) {
|
|
76
|
-
return new CdpWalletSigner(wallet);
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=cdp.js.map
|
package/dist/cdp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAiB;IAExC,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,2EAA2E;IAC3E,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,OAAmB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CACjB,MAKC,EACD,KAA4D,EAC5D,OAAgC;QAEhC,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAiC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACtF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,EAIrB;QACC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,0EAA0E;gBACxE,0EAA0E;gBAC1E,4CAA4C,CAC/C,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/payment.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PaymentInfo } from './types.js';
|
|
2
|
-
import type { ProofportSigner } from './signer.js';
|
|
3
|
-
/**
|
|
4
|
-
* Make payment for a proof session via x402 protocol.
|
|
5
|
-
*
|
|
6
|
-
* Uses EIP-3009 TransferWithAuthorization signed by the client,
|
|
7
|
-
* settled via x402 facilitator (facilitator pays gas).
|
|
8
|
-
* Works on both Base Sepolia (testnet) and Base (mainnet).
|
|
9
|
-
*
|
|
10
|
-
* @param signer - ProofportSigner (ethers, CDP MPC, or any implementation)
|
|
11
|
-
* @param payment - PaymentInfo from session or 402 response
|
|
12
|
-
* @param facilitatorUrl - Optional x402 facilitator URL (defaults to https://x402.dexter.cash)
|
|
13
|
-
* @param facilitatorHeaders - Optional headers for facilitator auth (e.g., CDP Bearer token)
|
|
14
|
-
* @returns Transaction hash
|
|
15
|
-
*/
|
|
16
|
-
export declare function makePayment(signer: ProofportSigner, payment: PaymentInfo, facilitatorUrl?: string, facilitatorHeaders?: Record<string, string>): Promise<string>;
|
|
17
|
-
//# sourceMappingURL=payment.d.ts.map
|
package/dist/payment.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAenD;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,MAAM,EACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1C,OAAO,CAAC,MAAM,CAAC,CA6GjB"}
|
package/dist/payment.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
const DEFAULT_X402_FACILITATOR = 'https://x402.dexter.cash';
|
|
3
|
-
const CHAIN_IDS = {
|
|
4
|
-
'base-sepolia': 84532,
|
|
5
|
-
'base': 8453,
|
|
6
|
-
};
|
|
7
|
-
// EIP-712 domain names per USDC contract (queried via name() on-chain)
|
|
8
|
-
const USDC_DOMAIN_NAMES = {
|
|
9
|
-
'base-sepolia': 'USDC',
|
|
10
|
-
'base': 'USD Coin',
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Make payment for a proof session via x402 protocol.
|
|
14
|
-
*
|
|
15
|
-
* Uses EIP-3009 TransferWithAuthorization signed by the client,
|
|
16
|
-
* settled via x402 facilitator (facilitator pays gas).
|
|
17
|
-
* Works on both Base Sepolia (testnet) and Base (mainnet).
|
|
18
|
-
*
|
|
19
|
-
* @param signer - ProofportSigner (ethers, CDP MPC, or any implementation)
|
|
20
|
-
* @param payment - PaymentInfo from session or 402 response
|
|
21
|
-
* @param facilitatorUrl - Optional x402 facilitator URL (defaults to https://x402.dexter.cash)
|
|
22
|
-
* @param facilitatorHeaders - Optional headers for facilitator auth (e.g., CDP Bearer token)
|
|
23
|
-
* @returns Transaction hash
|
|
24
|
-
*/
|
|
25
|
-
export async function makePayment(signer, payment, facilitatorUrl, facilitatorHeaders) {
|
|
26
|
-
const facilitator = facilitatorUrl || DEFAULT_X402_FACILITATOR;
|
|
27
|
-
const network = payment.network;
|
|
28
|
-
const chainId = CHAIN_IDS[network];
|
|
29
|
-
if (!chainId) {
|
|
30
|
-
throw new Error(`Unsupported network: ${network}`);
|
|
31
|
-
}
|
|
32
|
-
// Pad nonce to bytes32 (EIP-3009 requires bytes32 nonce)
|
|
33
|
-
const nonce = ethers.zeroPadValue(payment.nonce, 32);
|
|
34
|
-
// Validity window
|
|
35
|
-
const validAfter = 0;
|
|
36
|
-
const validBefore = Math.floor(Date.now() / 1000) + 3600; // 1 hour
|
|
37
|
-
// EIP-712 domain for USDC (domain name differs between testnet and mainnet)
|
|
38
|
-
const domain = {
|
|
39
|
-
name: USDC_DOMAIN_NAMES[network] || 'USD Coin',
|
|
40
|
-
version: '2',
|
|
41
|
-
chainId,
|
|
42
|
-
verifyingContract: payment.asset,
|
|
43
|
-
};
|
|
44
|
-
const types = {
|
|
45
|
-
TransferWithAuthorization: [
|
|
46
|
-
{ name: 'from', type: 'address' },
|
|
47
|
-
{ name: 'to', type: 'address' },
|
|
48
|
-
{ name: 'value', type: 'uint256' },
|
|
49
|
-
{ name: 'validAfter', type: 'uint256' },
|
|
50
|
-
{ name: 'validBefore', type: 'uint256' },
|
|
51
|
-
{ name: 'nonce', type: 'bytes32' },
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
const from = await signer.getAddress();
|
|
55
|
-
const message = {
|
|
56
|
-
from,
|
|
57
|
-
to: payment.recipient,
|
|
58
|
-
value: payment.amount,
|
|
59
|
-
validAfter,
|
|
60
|
-
validBefore,
|
|
61
|
-
nonce,
|
|
62
|
-
};
|
|
63
|
-
// Sign EIP-712 TransferWithAuthorization
|
|
64
|
-
const signature = await signer.signTypedData(domain, types, message);
|
|
65
|
-
// Settle via x402 facilitator (facilitator pays gas)
|
|
66
|
-
const settlePayload = {
|
|
67
|
-
x402Version: 1,
|
|
68
|
-
scheme: 'exact',
|
|
69
|
-
network,
|
|
70
|
-
paymentPayload: {
|
|
71
|
-
x402Version: 1,
|
|
72
|
-
scheme: 'exact',
|
|
73
|
-
network,
|
|
74
|
-
payload: {
|
|
75
|
-
signature,
|
|
76
|
-
authorization: {
|
|
77
|
-
from,
|
|
78
|
-
to: payment.recipient,
|
|
79
|
-
value: String(payment.amount),
|
|
80
|
-
validAfter: String(validAfter),
|
|
81
|
-
validBefore: String(validBefore),
|
|
82
|
-
nonce,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
paymentRequirements: {
|
|
87
|
-
scheme: 'exact',
|
|
88
|
-
network,
|
|
89
|
-
maxAmountRequired: String(payment.amount),
|
|
90
|
-
asset: payment.asset,
|
|
91
|
-
resource: `${payment.recipient}/proof`,
|
|
92
|
-
description: 'ZK proof generation payment',
|
|
93
|
-
mimeType: 'application/json',
|
|
94
|
-
payTo: payment.recipient,
|
|
95
|
-
extra: {
|
|
96
|
-
name: USDC_DOMAIN_NAMES[network] || 'USD Coin',
|
|
97
|
-
version: '2',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
const settleResponse = await fetch(`${facilitator}/settle`, {
|
|
102
|
-
method: 'POST',
|
|
103
|
-
headers: { 'Content-Type': 'application/json', ...facilitatorHeaders },
|
|
104
|
-
body: JSON.stringify(settlePayload),
|
|
105
|
-
});
|
|
106
|
-
if (!settleResponse.ok) {
|
|
107
|
-
const error = await settleResponse.text();
|
|
108
|
-
throw new Error(`x402 facilitator settle failed: ${error}`);
|
|
109
|
-
}
|
|
110
|
-
const settleResult = (await settleResponse.json());
|
|
111
|
-
// Check for error reason FIRST — facilitator may return a dummy txHash alongside an error
|
|
112
|
-
if (settleResult.errorReason) {
|
|
113
|
-
throw new Error(`x402 settle failed: ${settleResult.errorReason}`);
|
|
114
|
-
}
|
|
115
|
-
const txHash = settleResult.txHash || settleResult.transaction?.hash || settleResult.transaction;
|
|
116
|
-
if (!txHash) {
|
|
117
|
-
throw new Error(`x402 settle failed: no transaction hash`);
|
|
118
|
-
}
|
|
119
|
-
return txHash;
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=payment.js.map
|
package/dist/payment.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAE5D,MAAM,SAAS,GAA2B;IACxC,cAAc,EAAE,KAAK;IACrB,MAA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