dop-wallet-v6 1.3.34 → 1.3.36
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/.eslintrc.js +1 -11
- package/README.md +9 -367
- package/dist/services/dop/core/index.d.ts +0 -4
- package/dist/services/dop/core/index.js +0 -5
- package/dist/services/dop/core/index.js.map +1 -1
- package/dist/services/dop/core/prover.js +50 -1
- package/dist/services/dop/core/prover.js.map +1 -1
- package/dist/services/dop/core/react-native-init.js +1 -28
- package/dist/services/dop/core/react-native-init.js.map +1 -1
- package/dist/services/dop/crypto/custom-prover.d.ts +78 -0
- package/dist/services/dop/crypto/custom-prover.js +78 -0
- package/dist/services/dop/crypto/custom-prover.js.map +1 -0
- package/dist/services/dop/crypto/index.d.ts +1 -0
- package/dist/services/dop/crypto/index.js +18 -0
- package/dist/services/dop/crypto/index.js.map +1 -0
- package/dist/services/dop/index.d.ts +1 -0
- package/dist/services/dop/index.js +1 -0
- package/dist/services/dop/index.js.map +1 -1
- package/package.json +1 -1
- package/react-native.js +1 -13
- package/dist/services/dop/core/react-native-prover-setup.d.ts +0 -51
- package/dist/services/dop/core/react-native-prover-setup.js +0 -227
- package/dist/services/dop/core/react-native-prover-setup.js.map +0 -1
- package/dist/services/dop/crypto/mopro-circuit-loader.d.ts +0 -103
- package/dist/services/dop/crypto/mopro-circuit-loader.js +0 -308
- package/dist/services/dop/crypto/mopro-circuit-loader.js.map +0 -1
- package/dist/services/dop/crypto/mopro-prover-adapter.d.ts +0 -117
- package/dist/services/dop/crypto/mopro-prover-adapter.js +0 -243
- package/dist/services/dop/crypto/mopro-prover-adapter.js.map +0 -1
- package/dist/services/dop/crypto/user-rapidsnark-adapter.d.ts +0 -98
- package/dist/services/dop/crypto/user-rapidsnark-adapter.js +0 -226
- package/dist/services/dop/crypto/user-rapidsnark-adapter.js.map +0 -1
- package/dist/services/transactions/tx-encrypt-relayer.d.ts +0 -6
- package/dist/services/transactions/tx-encrypt-relayer.js +0 -80
- package/dist/services/transactions/tx-encrypt-relayer.js.map +0 -1
package/.eslintrc.js
CHANGED
|
@@ -63,25 +63,15 @@ module.exports = {
|
|
|
63
63
|
},
|
|
64
64
|
overrides: [
|
|
65
65
|
{
|
|
66
|
-
files: ['**/__tests__/**', './src/tests/**'
|
|
66
|
+
files: ['**/__tests__/**', './src/tests/**'],
|
|
67
67
|
rules: {
|
|
68
68
|
'@typescript-eslint/no-explicit-any': 0,
|
|
69
69
|
'@typescript-eslint/no-unsafe-member-access': 0,
|
|
70
|
-
'@typescript-eslint/no-unsafe-assignment': 0,
|
|
71
|
-
'@typescript-eslint/no-unsafe-call': 0,
|
|
72
|
-
'@typescript-eslint/no-unsafe-argument': 0,
|
|
73
|
-
'@typescript-eslint/no-unsafe-return': 0,
|
|
74
|
-
'@typescript-eslint/strict-boolean-expressions': 0,
|
|
75
|
-
'@typescript-eslint/restrict-template-expressions': 0,
|
|
76
|
-
'@typescript-eslint/no-non-null-assertion': 0,
|
|
77
70
|
'import/no-extraneous-dependencies': 0,
|
|
78
71
|
'no-console': 0,
|
|
79
72
|
'@typescript-eslint/no-unused-vars': 0,
|
|
80
73
|
'no-useless-concat': 0,
|
|
81
74
|
'@typescript-eslint/await-thenable': 0,
|
|
82
|
-
'no-plusplus': 0,
|
|
83
|
-
'no-constant-condition': 0,
|
|
84
|
-
'func-names': 0,
|
|
85
75
|
},
|
|
86
76
|
},
|
|
87
77
|
],
|
package/README.md
CHANGED
|
@@ -1,381 +1,23 @@
|
|
|
1
|
-
# DOP Wallet SDK v6
|
|
2
1
|
|
|
3
|
-
**Privacy-preserving blockchain transactions for Ethereum, Polygon, BNB Chain, Arbitrum, and Base**
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/dop-wallet-v6)
|
|
7
|
-
[](https://nodejs.org)
|
|
8
|
-
[](https://reactnative.dev)
|
|
3
|
+
# DOP Wallet SDK
|
|
9
4
|
|
|
10
|
-
The DOP Wallet SDK
|
|
5
|
+
The DOP Wallet SDK is an open-source project developed by [DOP](https://www.dop.org) contributors.
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
The Wallet SDK enables dApp and DeFi developers to provide privacy to users safely and conveniently on Ethereum, Polygon and BNB Chain.
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
The repo is written in TypeScript, and compatible with **Node.js**, **modern web browsers**, and **React Native**.
|
|
15
10
|
|
|
16
|
-
##
|
|
11
|
+
## 📱 React Native Support
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
The SDK_DOCS.md contains:
|
|
21
|
-
- Installation for Node.js, Browser, and React Native
|
|
22
|
-
- Complete API reference verified against working test files
|
|
23
|
-
- Step-by-step workflows for Shield, Unshield, and Private Transfers
|
|
24
|
-
- Real code examples that compile and run
|
|
25
|
-
- Error handling and performance tips
|
|
26
|
-
- React Native integration guide
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## ✨ Features
|
|
31
|
-
|
|
32
|
-
- 🔒 **Private Transfers**: Send ERC20, ERC721, ERC1155 tokens without revealing amounts or recipients
|
|
33
|
-
- 🛡️ **Shield/Unshield**: Convert between public and private token balances
|
|
34
|
-
- 📊 **Balance Queries**: View private balances across multiple chains
|
|
35
|
-
- 🔐 **Zero-Knowledge Proofs**: Generate and verify zk-SNARK proofs
|
|
36
|
-
- 🌐 **Multi-Chain**: Ethereum, Polygon, BNB Chain, Arbitrum, Base
|
|
37
|
-
- 📱 **React Native**: Full mobile support with custom proof generation
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## 🚀 Quick Start
|
|
42
|
-
|
|
43
|
-
### Installation
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm install dop-wallet-v6 dop-sharedmodels-v3
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
For Node.js:
|
|
50
|
-
```bash
|
|
51
|
-
npm install leveldown snarkjs
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
For React Native:
|
|
55
|
-
```bash
|
|
56
|
-
npm install react-native-get-random-values @react-native-async-storage/async-storage
|
|
57
|
-
npm install buffer assert stream-browserify crypto-browserify events
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Node.js Example
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import {
|
|
64
|
-
startDopEngine,
|
|
65
|
-
createOrImportDopWallet,
|
|
66
|
-
gasEstimateForEncrypt,
|
|
67
|
-
populateEncrypt,
|
|
68
|
-
getSerializedERC20Balances,
|
|
69
|
-
getProver
|
|
70
|
-
} from 'dop-wallet-v6';
|
|
71
|
-
import { NetworkName, NETWORK_CONFIG, TXIDVersion } from 'dop-sharedmodels-v3';
|
|
72
|
-
import { groth16 } from 'snarkjs';
|
|
73
|
-
import LevelDOWN from 'leveldown';
|
|
74
|
-
|
|
75
|
-
// Initialize
|
|
76
|
-
const db = new LevelDOWN('./dop-db');
|
|
77
|
-
await startDopEngine('my-app', db, false, artifactStore, false, false, true);
|
|
78
|
-
|
|
79
|
-
// Setup prover (required for transfers/unshield)
|
|
80
|
-
const prover = getProver();
|
|
81
|
-
prover.setSnarkJSGroth16(groth16);
|
|
82
|
-
|
|
83
|
-
// Create wallet
|
|
84
|
-
const { walletInfo, mnemonic } = await createOrImportDopWallet('encryption-key');
|
|
85
|
-
console.log('Save this mnemonic:', mnemonic);
|
|
86
|
-
|
|
87
|
-
// Shield tokens (3-step process)
|
|
88
|
-
const { gasEstimate } = await gasEstimateForEncrypt(/* ... */);
|
|
89
|
-
const txRequest = await populateEncrypt(/* ... */);
|
|
90
|
-
await publicWallet.sendTransaction(txRequest);
|
|
91
|
-
|
|
92
|
-
// Check balance
|
|
93
|
-
const balances = getSerializedERC20Balances(
|
|
94
|
-
TXIDVersion.V3_PoseidonMerkle,
|
|
95
|
-
NETWORK_CONFIG[NetworkName.Polygon].chain,
|
|
96
|
-
walletInfo.id
|
|
97
|
-
);
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**See [SDK_DOCS.md](./SDK_DOCS.md) for complete working examples.**
|
|
101
|
-
|
|
102
|
-
### React Native Example
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
import 'react-native-get-random-values'; // MUST BE FIRST!
|
|
106
|
-
import { Buffer } from 'buffer';
|
|
107
|
-
global.Buffer = global.Buffer || Buffer;
|
|
108
|
-
import 'dop-wallet-v6/react-native-shims';
|
|
109
|
-
|
|
110
|
-
import {
|
|
111
|
-
startDopEngine,
|
|
112
|
-
createOrImportDopWallet,
|
|
113
|
-
populateEncrypt,
|
|
114
|
-
getSerializedERC20Balances
|
|
115
|
-
} from 'dop-wallet-v6';
|
|
116
|
-
import MemDOWN from 'memdown';
|
|
117
|
-
|
|
118
|
-
// Initialize with React Native settings
|
|
119
|
-
const db = new MemDOWN();
|
|
120
|
-
await startDopEngine('my-app', db, __DEV__, artifactStore, true, false, __DEV__);
|
|
121
|
-
|
|
122
|
-
// Create wallet
|
|
123
|
-
const { walletInfo } = await createOrImportDopWallet('encryption-key');
|
|
124
|
-
|
|
125
|
-
// Shield works immediately
|
|
126
|
-
const txRequest = await populateEncrypt(/* ... */);
|
|
127
|
-
await wallet.sendTransaction(txRequest);
|
|
128
|
-
|
|
129
|
-
// Check balance
|
|
130
|
-
const balances = getSerializedERC20Balances(TXIDVersion.V3_PoseidonMerkle, chain, walletInfo.id);
|
|
131
|
-
|
|
132
|
-
// For private transfers, configure custom Rapidsnark prover
|
|
133
|
-
// See SDK_DOCS.md React Native section
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## 📚 Documentation
|
|
139
|
-
|
|
140
|
-
**📖 [SDK_DOCS.md](./SDK_DOCS.md)** - Complete unified documentation (RECOMMENDED)
|
|
141
|
-
|
|
142
|
-
The SDK_DOCS.md contains everything you need:
|
|
143
|
-
- Installation for all platforms
|
|
144
|
-
- Complete API reference verified against tests
|
|
145
|
-
- Step-by-step workflows with real code
|
|
146
|
-
- React Native integration guide
|
|
147
|
-
- Error handling and performance tips
|
|
148
|
-
|
|
149
|
-
### Quick Navigation
|
|
150
|
-
|
|
151
|
-
- **New to DOP?** → Start with [SDK_DOCS.md](./SDK_DOCS.md)
|
|
152
|
-
- **Looking for specific function?** → See API Reference section in SDK_DOCS.md
|
|
153
|
-
- **React Native setup?** → See React Native section in SDK_DOCS.md
|
|
154
|
-
- **Complete workflows?** → See Complete Workflows section in SDK_DOCS.md
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## 🔧 Environment Support
|
|
159
|
-
|
|
160
|
-
| Feature | Node.js | Browser | React Native |
|
|
161
|
-
|---------|---------|---------|--------------|
|
|
162
|
-
| Shield (encrypt) tokens | ✅ | ✅ | ✅ |
|
|
163
|
-
| View private balances | ✅ | ✅ | ✅ |
|
|
164
|
-
| Private transfers | ✅ | ✅ | ✅* |
|
|
165
|
-
| Unshield (decrypt) tokens | ✅ | ✅ | ✅* |
|
|
166
|
-
| Wallet management | ✅ | ✅ | ✅ |
|
|
167
|
-
| Transaction history | ✅ | ✅ | ✅ |
|
|
168
|
-
|
|
169
|
-
*React Native private transfers require custom Rapidsnark prover setup. See [REACT_NATIVE_USER_CONFIGURABLE_PROVER.md](./REACT_NATIVE_USER_CONFIGURABLE_PROVER.md).
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## 🎯 Use Cases
|
|
174
|
-
|
|
175
|
-
- **Privacy-preserving DeFi**: Let users trade and transfer without revealing balances
|
|
176
|
-
- **Private payroll**: Pay employees privately on-chain
|
|
177
|
-
- **Confidential treasury**: Manage organizational funds with selective transparency
|
|
178
|
-
- **Private gaming economies**: In-game token transfers without public visibility
|
|
179
|
-
- **Compliant privacy**: Optional selective transparency for regulatory requirements
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## 🛠️ Core Operations
|
|
184
|
-
|
|
185
|
-
### Important: Multi-Step Process
|
|
186
|
-
|
|
187
|
-
DOP transactions require 3 steps:
|
|
188
|
-
1. **Gas Estimation** - Calculate transaction cost
|
|
189
|
-
2. **Proof Generation** - Create zero-knowledge proof (30s-2min for transfers/unshield)
|
|
190
|
-
3. **Transaction** - Populate and submit transaction
|
|
191
|
-
|
|
192
|
-
### Shield Tokens (Public → Private)
|
|
13
|
+
This SDK now has comprehensive React Native support with optimized polyfills and easy integration:
|
|
193
14
|
|
|
194
15
|
```typescript
|
|
195
|
-
// Step 1: Estimate gas
|
|
196
|
-
const { gasEstimate } = await gasEstimateForEncrypt(/* ... */);
|
|
197
|
-
|
|
198
|
-
// Step 2: Populate transaction
|
|
199
|
-
const txRequest = await populateEncrypt(/* ... */);
|
|
200
|
-
|
|
201
|
-
// Step 3: Send
|
|
202
|
-
await wallet.sendTransaction(txRequest);
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Check Private Balances
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
const balances = getSerializedERC20Balances(
|
|
209
|
-
TXIDVersion.V3_PoseidonMerkle,
|
|
210
|
-
chain,
|
|
211
|
-
walletId
|
|
212
|
-
);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Private Transfer
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
// Step 1: Estimate gas
|
|
219
|
-
const { gasEstimate } = await gasEstimateForUnprovenTransfer(/* ... */);
|
|
220
|
-
|
|
221
|
-
// Step 2: Generate proof (1-2 minutes)
|
|
222
|
-
const { proof, publicInputs } = await generateTransferProofForExplorer(/* ... */);
|
|
223
|
-
|
|
224
|
-
// Step 3: Populate and send
|
|
225
|
-
const txRequest = await populateProvedTransfer(/* ... */);
|
|
226
|
-
await wallet.sendTransaction(txRequest);
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### Unshield Tokens (Private → Public)
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
// Step 1: Estimate gas
|
|
233
|
-
const { gasEstimate } = await gasEstimateForUnprovenDecrypt(/* ... */);
|
|
234
|
-
|
|
235
|
-
// Step 2: Generate proof (30s-2min)
|
|
236
|
-
const { proof, publicInputs } = await generateDecryptToOriginProof(/* ... */);
|
|
237
|
-
|
|
238
|
-
// Step 3: Populate and send
|
|
239
|
-
const txRequest = await populateProvedDecrypt(/* ... */);
|
|
240
|
-
await wallet.sendTransaction(txRequest);
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**See [SDK_DOCS.md](./SDK_DOCS.md) for complete working examples.**
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## 🌐 Supported Networks
|
|
248
|
-
|
|
249
|
-
- **Ethereum Mainnet**
|
|
250
|
-
- **Polygon**
|
|
251
|
-
- **BNB Chain**
|
|
252
|
-
- **Arbitrum**
|
|
253
|
-
- **Base**
|
|
254
|
-
|
|
255
|
-
All networks support ERC20, ERC721, and ERC1155 tokens.
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## 📱 React Native Setup
|
|
260
|
-
|
|
261
|
-
### Prerequisites
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
npm install react-native-get-random-values @react-native-async-storage/async-storage
|
|
265
|
-
npm install buffer assert stream-browserify crypto-browserify events
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### Entry Point Setup (CRITICAL)
|
|
269
|
-
|
|
270
|
-
**At the very top of index.js or App.js:**
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
// MUST BE FIRST IMPORTS
|
|
274
16
|
import 'react-native-get-random-values';
|
|
275
|
-
import {
|
|
276
|
-
global.Buffer = global.Buffer || Buffer;
|
|
277
|
-
|
|
278
|
-
// Import DOP shims
|
|
279
|
-
import 'dop-wallet-v6/react-native-shims';
|
|
280
|
-
|
|
281
|
-
// Now your app code
|
|
17
|
+
import { DopWallet } from 'dop-wallet-v6/react-native';
|
|
282
18
|
```
|
|
283
19
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
```typescript
|
|
287
|
-
import { startDopEngine } from 'dop-wallet-v6';
|
|
288
|
-
import MemDOWN from 'memdown';
|
|
289
|
-
|
|
290
|
-
const db = new MemDOWN();
|
|
291
|
-
await startDopEngine(
|
|
292
|
-
'my-rn-app',
|
|
293
|
-
db,
|
|
294
|
-
__DEV__,
|
|
295
|
-
artifactStore,
|
|
296
|
-
true, // useNativeArtifacts for React Native
|
|
297
|
-
false,
|
|
298
|
-
__DEV__
|
|
299
|
-
);
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### What Works Out of the Box
|
|
303
|
-
|
|
304
|
-
- ✅ Shield tokens
|
|
305
|
-
- ✅ Check balances
|
|
306
|
-
- ✅ Wallet management
|
|
307
|
-
- ❌ Private transfers (needs Rapidsnark)
|
|
308
|
-
- ❌ Unshield (needs Rapidsnark)
|
|
309
|
-
|
|
310
|
-
**📖 Complete React Native Guide**: See React Native section in [SDK_DOCS.md](./SDK_DOCS.md)
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
## 🔐 Security
|
|
315
|
-
|
|
316
|
-
- **Zero-Knowledge Proofs**: Transactions are cryptographically private
|
|
317
|
-
- **Client-Side Keys**: Private keys never leave user's device
|
|
318
|
-
- **Open Source**: Fully auditable codebase
|
|
319
|
-
- **BIP39 Mnemonics**: Standard 12/24-word recovery phrases
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
## 🤝 Contributing
|
|
324
|
-
|
|
325
|
-
Contributions are welcome! Please:
|
|
326
|
-
|
|
327
|
-
1. Fork the repository
|
|
328
|
-
2. Create a feature branch
|
|
329
|
-
3. Make your changes with tests
|
|
330
|
-
4. Submit a pull request
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
## 📄 License
|
|
335
|
-
|
|
336
|
-
MIT License - see [LICENSE](LICENSE) file for details
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## 🆘 Support
|
|
341
|
-
|
|
342
|
-
- **Documentation**: [SDK_DOCS.md](./SDK_DOCS.md)
|
|
343
|
-
- **Issues**: [GitHub Issues](https://github.com/VAR-META-Tech/new-dop-wallet-v3/issues)
|
|
344
|
-
- **Website**: [https://www.dop.org](https://www.dop.org)
|
|
345
|
-
|
|
346
|
-
---
|
|
347
|
-
|
|
348
|
-
## 🏗️ Architecture
|
|
349
|
-
|
|
350
|
-
```
|
|
351
|
-
Application
|
|
352
|
-
↓
|
|
353
|
-
DOP Wallet SDK
|
|
354
|
-
↓
|
|
355
|
-
├─ DOP Engine (core logic)
|
|
356
|
-
├─ Merkletree Sync (blockchain scanning)
|
|
357
|
-
├─ Proof Generation
|
|
358
|
-
│ ├─ SnarkJS (Node.js/Browser)
|
|
359
|
-
│ └─ Rapidsnark (React Native - custom setup required)
|
|
360
|
-
└─ Blockchain Interface (ethers.js)
|
|
361
|
-
↓
|
|
362
|
-
Ethereum, Polygon, BNB Chain, Arbitrum, Base
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
---
|
|
366
|
-
|
|
367
|
-
## 📊 Status
|
|
368
|
-
|
|
369
|
-
**Version**: 1.3.32
|
|
370
|
-
**Status**: Production Ready ✅
|
|
371
|
-
**Last Updated**: December 7, 2025
|
|
372
|
-
|
|
373
|
-
**Recent Updates:**
|
|
374
|
-
- ✅ Comprehensive SDK documentation rewrite
|
|
375
|
-
- ✅ API verified against working test files
|
|
376
|
-
- ✅ Complete workflows with real code examples
|
|
377
|
-
- ✅ React Native integration guide
|
|
20
|
+
**📚 Quick Start:** See [REACT_NATIVE_INTEGRATION_GUIDE.md](./REACT_NATIVE_INTEGRATION_GUIDE.md) for complete setup instructions.
|
|
378
21
|
|
|
379
|
-
|
|
22
|
+
**🔧 Verify Compatibility:** Run `npm run verify-rn-compatibility` to ensure your setup is correct.
|
|
380
23
|
|
|
381
|
-
**Built by the DOP community**
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export * from './artifacts';
|
|
2
2
|
export * from './init';
|
|
3
3
|
export * from './react-native-init';
|
|
4
|
-
export * from './react-native-prover-setup';
|
|
5
4
|
export * from './engine';
|
|
6
5
|
export * from './load-provider';
|
|
7
6
|
export * from './merkletree';
|
|
8
7
|
export * from './prover';
|
|
9
8
|
export * from './providers';
|
|
10
9
|
export * from './encrypts';
|
|
11
|
-
export * from '../crypto/react-native-crypto-provider';
|
|
12
|
-
export * from '../crypto/react-native-rapidsnark-prover';
|
|
13
|
-
export * from '../crypto/user-rapidsnark-adapter';
|
|
@@ -17,15 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./artifacts"), exports);
|
|
18
18
|
__exportStar(require("./init"), exports);
|
|
19
19
|
__exportStar(require("./react-native-init"), exports);
|
|
20
|
-
__exportStar(require("./react-native-prover-setup"), exports);
|
|
21
20
|
__exportStar(require("./engine"), exports);
|
|
22
21
|
__exportStar(require("./load-provider"), exports);
|
|
23
22
|
__exportStar(require("./merkletree"), exports);
|
|
24
23
|
__exportStar(require("./prover"), exports);
|
|
25
24
|
__exportStar(require("./providers"), exports);
|
|
26
25
|
__exportStar(require("./encrypts"), exports);
|
|
27
|
-
// Export React Native crypto provider utilities
|
|
28
|
-
__exportStar(require("../crypto/react-native-crypto-provider"), exports);
|
|
29
|
-
__exportStar(require("../crypto/react-native-rapidsnark-prover"), exports);
|
|
30
|
-
__exportStar(require("../crypto/user-rapidsnark-adapter"), exports);
|
|
31
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/dop/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,sDAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/dop/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,sDAAoC;AACpC,2CAAyB;AACzB,kDAAgC;AAChC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,6CAA2B","sourcesContent":["export * from './artifacts';\nexport * from './init';\nexport * from './react-native-init';\nexport * from './engine';\nexport * from './load-provider';\nexport * from './merkletree';\nexport * from './prover';\nexport * from './providers';\nexport * from './encrypts';\n"]}
|
|
@@ -3,12 +3,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getProver = void 0;
|
|
4
4
|
const engine_1 = require("./engine");
|
|
5
5
|
const dop_sharedmodels_v3_1 = require("dop-sharedmodels-v3");
|
|
6
|
+
const custom_prover_1 = require("../crypto/custom-prover");
|
|
7
|
+
/**
|
|
8
|
+
* Determines circuitId from formatted inputs
|
|
9
|
+
* DOP circuits are named like "3x2" (3 nullifiers, 2 commitments)
|
|
10
|
+
*/
|
|
11
|
+
function getCircuitIdFromInputs(formattedInputs) {
|
|
12
|
+
// Count nullifiers (non-zero entries)
|
|
13
|
+
const nullifierCount = formattedInputs.nullifiers?.filter((n) => n !== undefined && n !== null && BigInt(n) !== BigInt(0)).length || 0;
|
|
14
|
+
// Count commitments (non-zero entries)
|
|
15
|
+
const commitmentCount = formattedInputs.commitmentsOut?.filter((c) => c !== undefined && c !== null && BigInt(c) !== BigInt(0)).length || 0;
|
|
16
|
+
return `${nullifierCount}x${commitmentCount}`;
|
|
17
|
+
}
|
|
18
|
+
let proverIntercepted = false;
|
|
6
19
|
const getProver = () => {
|
|
7
20
|
const engine = (0, engine_1.getEngine)();
|
|
8
21
|
if (!(0, dop_sharedmodels_v3_1.isDefined)(engine)) {
|
|
9
22
|
throw new Error('DOP Engine not yet init. Please reload your app or try again.');
|
|
10
23
|
}
|
|
11
|
-
|
|
24
|
+
const prover = engine.prover;
|
|
25
|
+
// Intercept groth16.fullProveDop only once
|
|
26
|
+
if (!proverIntercepted && prover.groth16) {
|
|
27
|
+
proverIntercepted = true;
|
|
28
|
+
const originalFullProveDop = prover.groth16.fullProveDop;
|
|
29
|
+
// Wrap fullProveDop to check for custom prover
|
|
30
|
+
prover.groth16.fullProveDop = async (formattedInputs, wasm, zkey, logger, dat, progressCallback) => {
|
|
31
|
+
// Check if custom prover is available
|
|
32
|
+
if ((0, custom_prover_1.hasCustomRapidsnarkProver)()) {
|
|
33
|
+
const customProver = (0, custom_prover_1.getCustomRapidsnarkProver)();
|
|
34
|
+
if (!customProver) {
|
|
35
|
+
throw new Error('Custom prover is null');
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
// Determine circuit ID from inputs
|
|
39
|
+
const circuitId = getCircuitIdFromInputs(formattedInputs);
|
|
40
|
+
logger.debug(`[Custom Prover] Using custom prover for circuit ${circuitId}`);
|
|
41
|
+
// Call custom prover (e.g., backend server)
|
|
42
|
+
const proof = await customProver.generateProof(circuitId, new Uint8Array(zkey), formattedInputs, progressCallback);
|
|
43
|
+
logger.debug(`[Custom Prover] Proof generated successfully via custom prover`);
|
|
44
|
+
// Return in expected format
|
|
45
|
+
return {
|
|
46
|
+
proof,
|
|
47
|
+
publicSignals: proof.publicSignals ?? []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
+
logger.debug(`[Custom Prover] Error: ${errorMessage}`);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// No custom prover - use original implementation
|
|
57
|
+
return originalFullProveDop(formattedInputs, wasm, zkey, logger, dat, progressCallback);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return prover;
|
|
12
61
|
};
|
|
13
62
|
exports.getProver = getProver;
|
|
14
63
|
//# sourceMappingURL=prover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover.js","sourceRoot":"","sources":["../../../../src/services/dop/core/prover.ts"],"names":[],"mappings":";;;AAMA,qCAAqC;AACrC,6DAAgD;
|
|
1
|
+
{"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InputsDop,\n SnarkJSGroth16,\n Proof,\n Prover,\n} from 'dop-engine-v3';\nimport { getEngine } from './engine';\nimport { isDefined } from 'dop-sharedmodels-v3';\nimport { \n hasCustomRapidsnarkProver, \n getCustomRapidsnarkProver \n} from '../crypto/custom-prover';\n\ntype ProverProgressCallback = (progress: number) => void;\n\n/**\n * Determines circuitId from formatted inputs\n * DOP circuits are named like \"3x2\" (3 nullifiers, 2 commitments)\n */\nfunction getCircuitIdFromInputs(formattedInputs: FormattedCircuitInputsDop): string {\n // Count nullifiers (non-zero entries)\n const nullifierCount = formattedInputs.nullifiers?.filter(\n (n: any) => n !== undefined && n !== null && BigInt(n) !== BigInt(0)\n ).length || 0;\n \n // Count commitments (non-zero entries)\n const commitmentCount = formattedInputs.commitmentsOut?.filter(\n (c: any) => c !== undefined && c !== null && BigInt(c) !== BigInt(0)\n ).length || 0;\n \n return `${nullifierCount}x${commitmentCount}`;\n}\n\nlet proverIntercepted = false;\n\nexport const getProver = (): Prover => {\n const engine = getEngine();\n if (!isDefined(engine)) {\n throw new Error(\n 'DOP Engine not yet init. Please reload your app or try again.',\n );\n }\n \n const prover = engine.prover;\n \n // Intercept groth16.fullProveDop only once\n if (!proverIntercepted && prover.groth16) {\n proverIntercepted = true;\n \n const originalFullProveDop = prover.groth16.fullProveDop;\n \n // Wrap fullProveDop to check for custom prover\n prover.groth16.fullProveDop = async (\n formattedInputs: FormattedCircuitInputsDop,\n wasm: any,\n zkey: ArrayLike<number>,\n logger: { debug: (log: string) => void },\n dat: any,\n progressCallback: ProverProgressCallback\n ) => {\n // Check if custom prover is available\n if (hasCustomRapidsnarkProver()) {\n const customProver = getCustomRapidsnarkProver();\n \n if (!customProver) {\n throw new Error('Custom prover is null');\n }\n \n try {\n // Determine circuit ID from inputs\n const circuitId = getCircuitIdFromInputs(formattedInputs);\n \n logger.debug(`[Custom Prover] Using custom prover for circuit ${circuitId}`);\n \n // Call custom prover (e.g., backend server)\n const proof = await customProver.generateProof(\n circuitId,\n new Uint8Array(zkey),\n formattedInputs,\n progressCallback\n );\n \n logger.debug(`[Custom Prover] Proof generated successfully via custom prover`);\n \n // Return in expected format\n return {\n proof,\n publicSignals: (proof as any).publicSignals ?? []\n };\n } catch (error: unknown) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.debug(`[Custom Prover] Error: ${errorMessage}`);\n throw error;\n }\n }\n \n // No custom prover - use original implementation\n return originalFullProveDop(\n formattedInputs,\n wasm,\n zkey,\n logger,\n dat,\n progressCallback\n );\n };\n }\n \n return prover;\n};\n\nexport { FormattedCircuitInputsDop, Proof, SnarkJSGroth16 };\n"]}
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.startDopEngineReactNative = exports.ReactNativeLevelDB = void 0;
|
|
27
4
|
const init_1 = require("./init");
|
|
@@ -616,12 +593,8 @@ const startDopEngineReactNative = async (walletSource, shouldDebug, artifactStor
|
|
|
616
593
|
});
|
|
617
594
|
}
|
|
618
595
|
// Initialize the DOP Engine with the React Native database
|
|
619
|
-
|
|
596
|
+
return (0, init_1.startDopEngine)(walletSource, db, // Cast to any since TypeScript doesn't know about our custom implementation
|
|
620
597
|
shouldDebug, artifactStore, useNativeArtifacts, skipMerkletreeScans, verboseScanLogging);
|
|
621
|
-
// CRITICAL: Auto-setup Rapidsnark prover for React Native
|
|
622
|
-
// This enables proof generation for transfers, shield, and unshield operations
|
|
623
|
-
const { autoSetupProverForReactNative } = await Promise.resolve().then(() => __importStar(require('./react-native-prover-setup')));
|
|
624
|
-
await autoSetupProverForReactNative();
|
|
625
598
|
};
|
|
626
599
|
exports.startDopEngineReactNative = startDopEngineReactNative;
|
|
627
600
|
//# sourceMappingURL=react-native-init.js.map
|