@permissionless-technologies/upp-sdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -145
- package/dist/{chunk-5AKBSMEQ.cjs → chunk-43U5RGYE.cjs} +2 -2
- package/dist/{chunk-5AKBSMEQ.cjs.map → chunk-43U5RGYE.cjs.map} +1 -1
- package/dist/{chunk-KIKBPJXJ.cjs → chunk-46GGZ3TC.cjs} +15 -15
- package/dist/{chunk-KIKBPJXJ.cjs.map → chunk-46GGZ3TC.cjs.map} +1 -1
- package/dist/{chunk-OQDSHMXU.js → chunk-64RTC5ML.js} +2 -2
- package/dist/{chunk-OQDSHMXU.js.map → chunk-64RTC5ML.js.map} +1 -1
- package/dist/{chunk-PWHOUQOZ.js → chunk-CZ23JMAQ.js} +15 -15
- package/dist/{chunk-PWHOUQOZ.js.map → chunk-CZ23JMAQ.js.map} +1 -1
- package/dist/core/index.cjs +7 -7
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.js +2 -2
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.js +1 -1
- package/dist/react/index.cjs +5 -5
- package/dist/react/index.js +5 -5
- package/dist/{transfer-KTCXKHS4.js → transfer-4OF2JWXX.js} +3 -3
- package/dist/{transfer-KTCXKHS4.js.map → transfer-4OF2JWXX.js.map} +1 -1
- package/dist/{transfer-2UDHDS7Q.cjs → transfer-SA4NHNJ7.cjs} +9 -9
- package/dist/{transfer-2UDHDS7Q.cjs.map → transfer-SA4NHNJ7.cjs.map} +1 -1
- package/package.json +3 -2
- package/src/deployments/11155111.json +13 -13
- package/stwo-prover/pkg/upp_stwo_prover.d.ts +79 -0
- package/stwo-prover/pkg/upp_stwo_prover.js +293 -0
- package/stwo-prover/pkg/upp_stwo_prover_bg.wasm +0 -0
- package/stwo-prover/pkg/upp_stwo_prover_bg.wasm.d.ts +13 -0
package/README.md
CHANGED
|
@@ -2,193 +2,153 @@
|
|
|
2
2
|
|
|
3
3
|
Privacy-preserving token operations for any ERC20 token.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **Multi-token support**: Shield any ERC20 into a single privacy pool
|
|
8
|
-
- **Large anonymity set**: All token users share one Merkle tree
|
|
9
|
-
- **Compliance-ready**: ASP-based whitelists with ragequit protection
|
|
10
|
-
- **Modern stack**: Built on viem, not ethers.js
|
|
11
|
-
|
|
12
|
-
## Package Structure
|
|
13
|
-
|
|
14
|
-
The SDK is published as a single npm package with subpath exports:
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
// Core crypto and utilities
|
|
18
|
-
import { poseidon, computeSharedSecret } from '@upp/sdk/core'
|
|
19
|
-
|
|
20
|
-
// Key derivation
|
|
21
|
-
import { deriveKeysFromSignature } from '@upp/sdk/keys'
|
|
5
|
+
**[Documentation](https://permissionless-technologies.com/docs/upp/quickstart)** | **[Learn more](https://permissionless-technologies.com/upp)**
|
|
22
6
|
|
|
23
|
-
|
|
24
|
-
import { UPPAccountProvider, useUPPAccount } from '@upp/sdk/react'
|
|
25
|
-
|
|
26
|
-
// Indexer for note scanning
|
|
27
|
-
import { makeRpcIndexer } from '@upp/sdk/indexer'
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Why not separate packages?**
|
|
31
|
-
|
|
32
|
-
We considered splitting into `@upp/core`, `@upp/react`, etc. (like Kohaku), but chose a single package because:
|
|
33
|
-
|
|
34
|
-
1. **Same developer experience** - Subpath exports work identically to separate packages
|
|
35
|
-
2. **Tree-shaking works** - Modern bundlers only include what you import
|
|
36
|
-
3. **Simpler versioning** - No cross-package dependency management
|
|
37
|
-
4. **Prototype-appropriate** - Less operational overhead
|
|
7
|
+
## Features
|
|
38
8
|
|
|
39
|
-
|
|
9
|
+
- **Multi-token support** — Shield any ERC20 into a single privacy pool
|
|
10
|
+
- **Large anonymity set** — All token users share one Merkle tree
|
|
11
|
+
- **Compliance-ready** — Pluggable ASP (Association Set Provider) with ragequit fallback
|
|
12
|
+
- **Pluggable architecture** — Bring your own account adapter, ASP provider, storage backend
|
|
13
|
+
- **SNARK + STARK** — Dual proof system support (BN254 + Circle STARK)
|
|
14
|
+
- **Modern stack** — Built on viem, TypeScript strict mode, ESM-first
|
|
40
15
|
|
|
41
16
|
## Installation
|
|
42
17
|
|
|
43
18
|
```bash
|
|
44
|
-
npm install @upp
|
|
19
|
+
npm install @permissionless-technologies/upp-sdk viem
|
|
45
20
|
```
|
|
46
21
|
|
|
47
|
-
##
|
|
22
|
+
## Subpath Exports
|
|
48
23
|
|
|
49
24
|
```typescript
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
import { sepolia } from 'viem/chains'
|
|
53
|
-
|
|
54
|
-
// Create viem clients
|
|
55
|
-
const publicClient = createPublicClient({
|
|
56
|
-
chain: sepolia,
|
|
57
|
-
transport: http(),
|
|
58
|
-
})
|
|
25
|
+
// Everything
|
|
26
|
+
import { ... } from '@permissionless-technologies/upp-sdk'
|
|
59
27
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
transport: http(),
|
|
63
|
-
})
|
|
28
|
+
// Core: notes, proofs, stealth addresses, transfers
|
|
29
|
+
import { ... } from '@permissionless-technologies/upp-sdk/core'
|
|
64
30
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
publicClient,
|
|
68
|
-
walletClient,
|
|
69
|
-
poolAddress: '0x...',
|
|
70
|
-
aspHubAddress: '0x...',
|
|
71
|
-
})
|
|
31
|
+
// Keys: derivation, viewing keys
|
|
32
|
+
import { ... } from '@permissionless-technologies/upp-sdk/keys'
|
|
72
33
|
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
token: '0xUSDC...',
|
|
76
|
-
amount: 1000n * 10n ** 6n,
|
|
77
|
-
})
|
|
34
|
+
// React hooks (requires React 18+ and wagmi)
|
|
35
|
+
import { ... } from '@permissionless-technologies/upp-sdk/react'
|
|
78
36
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
note: myNote,
|
|
82
|
-
recipient: recipientStealthAddress,
|
|
83
|
-
amount: 500n * 10n ** 6n,
|
|
84
|
-
})
|
|
37
|
+
// Indexer: note scanning, storage adapters
|
|
38
|
+
import { ... } from '@permissionless-technologies/upp-sdk/indexer'
|
|
85
39
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
note: myNote,
|
|
89
|
-
amount: 500n * 10n ** 6n,
|
|
90
|
-
recipient: '0xMyAddress...',
|
|
91
|
-
aspId: 1,
|
|
92
|
-
})
|
|
40
|
+
// Utilities: poseidon, babyjubjub, merkle trees
|
|
41
|
+
import { ... } from '@permissionless-technologies/upp-sdk/utils'
|
|
93
42
|
```
|
|
94
43
|
|
|
95
|
-
##
|
|
96
|
-
|
|
97
|
-
### Prerequisites
|
|
98
|
-
|
|
99
|
-
- [Foundry](https://book.getfoundry.sh/getting-started/installation) for contract compilation and deployment
|
|
100
|
-
- [Node.js](https://nodejs.org/) 18+
|
|
101
|
-
- Local Ethereum node (Anvil recommended)
|
|
102
|
-
|
|
103
|
-
### Starting a Local Node
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
# Start Anvil with auto-mining
|
|
107
|
-
anvil
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Deploying Contracts
|
|
111
|
-
|
|
112
|
-
The SDK includes deployment scripts and automatic address extraction:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# 1. Deploy contracts to local Anvil
|
|
116
|
-
forge script src/contracts/script/DeployUPP.s.sol:DeployUPPLocal \
|
|
117
|
-
--rpc-url http://localhost:8545 \
|
|
118
|
-
--broadcast \
|
|
119
|
-
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
|
44
|
+
## Quick Start
|
|
120
45
|
|
|
121
|
-
|
|
122
|
-
node scripts/extract-deployment.js 31337
|
|
46
|
+
### React Application
|
|
123
47
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
48
|
+
```tsx
|
|
49
|
+
import { UPPAccountProvider, useUPPAccount, useShield } from '@permissionless-technologies/upp-sdk/react'
|
|
50
|
+
import { getDeployment } from '@permissionless-technologies/upp-sdk'
|
|
127
51
|
|
|
128
|
-
|
|
52
|
+
const deployment = getDeployment(11155111) // Sepolia
|
|
129
53
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"deployBlock": 2
|
|
54
|
+
function App() {
|
|
55
|
+
return (
|
|
56
|
+
<UPPAccountProvider chainId={11155111} ethAddress={address}>
|
|
57
|
+
<ShieldForm />
|
|
58
|
+
</UPPAccountProvider>
|
|
59
|
+
)
|
|
137
60
|
}
|
|
138
61
|
```
|
|
139
62
|
|
|
140
|
-
###
|
|
141
|
-
|
|
142
|
-
The SDK provides helpers to load deployment addresses:
|
|
63
|
+
### Standalone (Node.js / Custom Frontend)
|
|
143
64
|
|
|
144
65
|
```typescript
|
|
145
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
getDeployment,
|
|
68
|
+
registerDeployment,
|
|
69
|
+
NoteStore,
|
|
70
|
+
DirectAccountAdapter,
|
|
71
|
+
} from '@permissionless-technologies/upp-sdk'
|
|
72
|
+
import { makeRpcIndexer, createAutoAdapter } from '@permissionless-technologies/upp-sdk/indexer'
|
|
73
|
+
|
|
74
|
+
// Load deployment addresses
|
|
75
|
+
const deployment = getDeployment(11155111)
|
|
76
|
+
|
|
77
|
+
// Or register your own chain
|
|
78
|
+
registerDeployment(8453, {
|
|
79
|
+
UniversalPrivatePool: '0x...',
|
|
80
|
+
ASPRegistryHub: '0x...',
|
|
81
|
+
verifiers: { TransferVerifier: '0x...', MergeVerifier: '0x...', WithdrawVerifier: '0x...' },
|
|
82
|
+
chainId: 8453,
|
|
83
|
+
deployBlock: 12345678,
|
|
84
|
+
})
|
|
146
85
|
|
|
147
|
-
//
|
|
148
|
-
const
|
|
86
|
+
// Note storage (pluggable: IndexedDB, localStorage, memory, custom)
|
|
87
|
+
const storage = createAutoAdapter('my-app')
|
|
88
|
+
const noteStore = new NoteStore(storage)
|
|
89
|
+
await noteStore.load()
|
|
90
|
+
```
|
|
149
91
|
|
|
150
|
-
|
|
151
|
-
const deployment = getDeploymentOrThrow(31337)
|
|
92
|
+
## Architecture
|
|
152
93
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
94
|
+
```
|
|
95
|
+
@permissionless-technologies/upp-sdk
|
|
96
|
+
├── core/ # Notes, proofs, stealth addresses, transfers
|
|
97
|
+
├── keys/ # Key derivation (signature, direct, custom)
|
|
98
|
+
├── react/ # React hooks (useUPPAccount, useShield, etc.)
|
|
99
|
+
├── indexer/ # Note scanning + pluggable storage
|
|
100
|
+
├── utils/ # Poseidon, BabyJubJub, Merkle trees
|
|
101
|
+
├── contracts/ # ABIs + Solidity interfaces
|
|
102
|
+
└── deployments/ # Per-chain contract addresses
|
|
158
103
|
```
|
|
159
104
|
|
|
160
|
-
###
|
|
161
|
-
|
|
162
|
-
The local deployment includes a test ERC20 token with an ETH-to-token swap:
|
|
105
|
+
### Pluggable Interfaces
|
|
163
106
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
abi: USSC_ABI,
|
|
171
|
-
functionName: 'mintWithEth',
|
|
172
|
-
}),
|
|
173
|
-
})
|
|
174
|
-
```
|
|
107
|
+
| Interface | Purpose | Built-in |
|
|
108
|
+
|-----------|---------|----------|
|
|
109
|
+
| `IAccountAdapter` | Key derivation source | `DirectAccountAdapter`, signature-based |
|
|
110
|
+
| `IASPProvider` | Compliance layer | Optional (ragequit always available) |
|
|
111
|
+
| `StorageAdapter` | Note persistence | IndexedDB, localStorage, memory |
|
|
112
|
+
| `NoteStore` | Note state management | Dedup, balance, status tracking |
|
|
175
113
|
|
|
176
114
|
## Contract ABIs
|
|
177
115
|
|
|
178
|
-
The SDK exports ABIs for all contracts:
|
|
179
|
-
|
|
180
116
|
```typescript
|
|
181
117
|
import {
|
|
182
118
|
UNIVERSAL_PRIVATE_POOL_ABI,
|
|
183
119
|
ASP_REGISTRY_HUB_ABI,
|
|
184
|
-
|
|
185
|
-
} from '@upp
|
|
120
|
+
TEST_STABLE_TOKEN_ABI,
|
|
121
|
+
} from '@permissionless-technologies/upp-sdk'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Solidity interfaces are included for integration:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
node_modules/@permissionless-technologies/upp-sdk/src/contracts/interfaces/
|
|
128
|
+
├── IUniversalPrivatePool.sol
|
|
129
|
+
├── IASPRegistry.sol
|
|
130
|
+
└── IVerifiers.sol
|
|
186
131
|
```
|
|
187
132
|
|
|
188
|
-
##
|
|
133
|
+
## Deployments
|
|
189
134
|
|
|
190
|
-
|
|
135
|
+
| Chain | Chain ID | Status |
|
|
136
|
+
|-------|----------|--------|
|
|
137
|
+
| Anvil (local) | 31337 | Built-in |
|
|
138
|
+
| Sepolia | 11155111 | Built-in |
|
|
139
|
+
|
|
140
|
+
Custom chains: use `registerDeployment()` at app initialization.
|
|
141
|
+
|
|
142
|
+
## Local Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm install # Install dependencies
|
|
146
|
+
npm run build # Build (ESM + CJS)
|
|
147
|
+
npm run dev # Watch mode
|
|
148
|
+
npm test # Run tests (176 passing)
|
|
149
|
+
npm run deploy:local # Deploy to local Anvil
|
|
150
|
+
```
|
|
191
151
|
|
|
192
152
|
## License
|
|
193
153
|
|
|
194
|
-
|
|
154
|
+
[AGPL-3.0-or-later](./LICENSE)
|
|
@@ -1004,5 +1004,5 @@ exports.makeRpcIndexer = makeRpcIndexer;
|
|
|
1004
1004
|
exports.matchesSearchTag = matchesSearchTag;
|
|
1005
1005
|
exports.tryDecryptNote = tryDecryptNote;
|
|
1006
1006
|
exports.unpackNoteData = unpackNoteData;
|
|
1007
|
-
//# sourceMappingURL=chunk-
|
|
1008
|
-
//# sourceMappingURL=chunk-
|
|
1007
|
+
//# sourceMappingURL=chunk-43U5RGYE.cjs.map
|
|
1008
|
+
//# sourceMappingURL=chunk-43U5RGYE.cjs.map
|