@fairblock/stabletrust 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +304 -0
- package/package.json +41 -0
- package/pkg/LICENSE +176 -0
- package/pkg/confidential_transfer_proof_generation.d.ts +65 -0
- package/pkg/confidential_transfer_proof_generation.js +654 -0
- package/pkg/confidential_transfer_proof_generation_bg.wasm +0 -0
- package/pkg/confidential_transfer_proof_generation_bg.wasm.d.ts +17 -0
- package/pkg/package.json +28 -0
- package/pkg/proof_generator_wasm_bg.wasm +0 -0
- package/src/client.js +885 -0
- package/src/constants.js +32 -0
- package/src/crypto.js +90 -0
- package/src/index.d.ts +275 -0
- package/src/index.js +5 -0
- package/src/utils.js +84 -0
- package/src/wasm-loader.js +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# @fairblock/stabletrust
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The StableTrust SDK by Fairblock provides a robust interface for executing confidential transfers using homomorphic encryption and zero-knowledge proofs. This package enables developers to integrate confidentiality features directly into their applications, allowing for secure token deposits, private transfers, and withdrawals while maintaining the integrity and auditability of the underlying blockchain transactions.
|
|
6
|
+
|
|
7
|
+
For a comprehensive technical understanding of the architecture and cryptographic primitives, please refer to the following documentation:
|
|
8
|
+
|
|
9
|
+
- **Technical Overview**: [Fairblock Confidential Transfers](https://docs.fairblock.network/docs/confidential_transfers/technical_overview)
|
|
10
|
+
- **StableTrust Protocol**: [StableTrust Documentation](https://docs.fairblock.network/docs/confidential_transfers/stabletrust)
|
|
11
|
+
- **Confidential Transactions**: [Transaction Mechanics](https://docs.fairblock.network/docs/confidential_transfers/confidential_transactions)
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
Before using this SDK, ensure you have the following installed:
|
|
16
|
+
|
|
17
|
+
- **Node.js**: Version 16.0 or higher
|
|
18
|
+
- **npm** or **yarn**: For package management
|
|
19
|
+
- **ethers.js**: Version 6.0 or higher (automatically installed as a dependency)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
To install the package in your project, execute the following command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @fairblock/stabletrust
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or with yarn:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
yarn add @fairblock/stabletrust
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Available Confidential Contract Addresses (Testnet)
|
|
36
|
+
|
|
37
|
+
The following contract addresses are available for confidential transfers on testnet networks. These are test deployments and should not be used with mainnet assets:
|
|
38
|
+
|
|
39
|
+
| Network | Chain ID | Contract Address |
|
|
40
|
+
| :------- | :------- | :------------------------------------------- |
|
|
41
|
+
| Stable | 2201 | `0x9261D8A9d5B66B202AC56E2BE738Df00D3ecAa4d` |
|
|
42
|
+
| Arc | 1244 | `0x840499150804Af011B4d0C4A8a968F18b8626e41` |
|
|
43
|
+
| Base | 84532 | `0x05ad3FF447930ad5B4085C07B4Ef9b10Aa0a58F2` |
|
|
44
|
+
| Ethereum | 11155111 | `0x7B5A0060dE15a1AA1b9712A0146145E9D01A1acA` |
|
|
45
|
+
| Arbitrum | 421614 | `0x5acE788EF0C9f7f902642001d639AD155fF29A6C` |
|
|
46
|
+
| Tempo | 42431 | `0x17176c409B66bb03d102215eeEdb34259Db0F5AD` |
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
The SDK revolves around the `ConfidentialTransferClient`, which manages interactions with the confidential transfer contract and handles the necessary cryptographic operations.
|
|
51
|
+
|
|
52
|
+
### Initialization
|
|
53
|
+
|
|
54
|
+
Import and initialize the client with your network configuration.
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { ConfidentialTransferClient } from "@fairblock/stabletrust";
|
|
58
|
+
import { ethers } from "ethers";
|
|
59
|
+
|
|
60
|
+
// Configuration for Arbitrum (example)
|
|
61
|
+
const client = new ConfidentialTransferClient(
|
|
62
|
+
"https://arb1.arbitrum.io/rpc",
|
|
63
|
+
"0x5acE788EF0C9f7f902642001d639AD155fF29A6C",
|
|
64
|
+
42161,
|
|
65
|
+
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Network Configuration Examples
|
|
69
|
+
|
|
70
|
+
For different networks, use the following configurations:
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// Base
|
|
74
|
+
const baseClient = new ConfidentialTransferClient(
|
|
75
|
+
"https://mainnet.base.org",
|
|
76
|
+
"0x05ad3FF447930ad5B4085C07B4Ef9b10Aa0a58F2",
|
|
77
|
+
8453,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Ethereum Mainnet
|
|
81
|
+
const ethClient = new ConfidentialTransferClient(
|
|
82
|
+
"https://eth.public.netzach.io",
|
|
83
|
+
"0x7B5A0060dE15a1AA1b9712A0146145E9D01A1acA",
|
|
84
|
+
1,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Tempo (Stablecoin chain with special fee handling)
|
|
88
|
+
const tempoClient = new ConfidentialTransferClient(
|
|
89
|
+
"https://tempo-rpc.example.com",
|
|
90
|
+
"0x17176c409B66bb03d102215eeEdb34259Db0F5AD",
|
|
91
|
+
42431,
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Note on Tempo Chain**: The Tempo network (chainId 42431) uses token-based fees instead of native currency. The SDK automatically handles fee payment using PathUSD when detected.
|
|
96
|
+
|
|
97
|
+
### Key Functions
|
|
98
|
+
|
|
99
|
+
The following methods are the primary entry points for interacting with the confidential system.
|
|
100
|
+
|
|
101
|
+
#### `deriveKeys(signer)`
|
|
102
|
+
|
|
103
|
+
Derives the encryption keypair for a wallet. These keys are used for all confidential operations.
|
|
104
|
+
|
|
105
|
+
- **Parameters**:
|
|
106
|
+
- `signer` (ethers.Signer): The ethers.js signer instance for the user.
|
|
107
|
+
- **Returns**: An object containing `publicKey` and `privateKey` (base64-encoded).
|
|
108
|
+
|
|
109
|
+
#### `ensureAccount(signer, options)`
|
|
110
|
+
|
|
111
|
+
Initializes or retrieves the cryptographic keys associated with an account. This step is required before performing any confidential operations. Automatically creates the account on-chain if it doesn't exist.
|
|
112
|
+
|
|
113
|
+
- **Parameters**:
|
|
114
|
+
- `signer` (ethers.Signer): The ethers.js signer instance for the user.
|
|
115
|
+
- `options` (object, optional):
|
|
116
|
+
- `waitForFinalization` (boolean): Wait for account finalization. Default: `true`
|
|
117
|
+
- `maxAttempts` (number): Maximum attempts to check finalization. Default: `30`
|
|
118
|
+
- **Returns**: An object containing the user's private and public keys for the confidential system.
|
|
119
|
+
|
|
120
|
+
#### `getBalance(address, privateKey, tokenAddress, options)`
|
|
121
|
+
|
|
122
|
+
Retrieves the decrypted balance for a specific token in the confidential account.
|
|
123
|
+
|
|
124
|
+
- **Parameters**:
|
|
125
|
+
- `address` (string): The account address.
|
|
126
|
+
- `privateKey` (string): The private key for decryption.
|
|
127
|
+
- `tokenAddress` (string): The token contract address.
|
|
128
|
+
- `options` (object, optional):
|
|
129
|
+
- `type` (string): Balance type—`'available'` or `'pending'`. Default: `'available'`
|
|
130
|
+
- **Returns**: An object containing `amount` (number) and `ciphertext` (string).
|
|
131
|
+
|
|
132
|
+
#### `deposit(signer, tokenAddress, amount, options)`
|
|
133
|
+
|
|
134
|
+
Deposits a specified amount of ERC20 tokens into the confidential contract, converting them into a "pending" confidential balance.
|
|
135
|
+
|
|
136
|
+
- **Parameters**:
|
|
137
|
+
- `signer` (ethers.Signer): The transaction signer.
|
|
138
|
+
- `tokenAddress` (string): The contract address of the ERC20 token.
|
|
139
|
+
- `amount` (bigint | string | number): The amount to deposit (ensure proper unit scaling).
|
|
140
|
+
- `options` (object, optional):
|
|
141
|
+
- `waitForFinalization` (boolean): Wait for deposit finalization. Default: `true`
|
|
142
|
+
- **Returns**: A transaction receipt.
|
|
143
|
+
|
|
144
|
+
#### `transfer(signer, recipientAddress, tokenAddress, amount, options)`
|
|
145
|
+
|
|
146
|
+
Executes a confidential transfer of tokens from the sender to a recipient. The amount and nature of the transfer are encrypted.
|
|
147
|
+
|
|
148
|
+
- **Parameters**:
|
|
149
|
+
- `signer` (ethers.Signer): The sender's signer.
|
|
150
|
+
- `recipientAddress` (string): The public address of the recipient.
|
|
151
|
+
- `tokenAddress` (string): The token contract address.
|
|
152
|
+
- `amount` (number): The amount to transfer.
|
|
153
|
+
- `options` (object, optional):
|
|
154
|
+
- `useOffchainVerify` (boolean): Use offchain verification. Default: `false`
|
|
155
|
+
- `waitForFinalization` (boolean): Wait for transfer finalization. Default: `true`
|
|
156
|
+
- **Returns**: A transaction receipt.
|
|
157
|
+
|
|
158
|
+
#### `applyPending(signer, options)`
|
|
159
|
+
|
|
160
|
+
Moves funds from the "pending" balance to the "available" balance. This is often necessary for the recipient to utilize received funds.
|
|
161
|
+
|
|
162
|
+
- **Parameters**:
|
|
163
|
+
- `signer` (ethers.Signer): The user's signer.
|
|
164
|
+
- `options` (object, optional):
|
|
165
|
+
- `waitForFinalization` (boolean): Wait for operation finalization. Default: `true`
|
|
166
|
+
- **Returns**: A transaction receipt.
|
|
167
|
+
|
|
168
|
+
#### `withdraw(signer, tokenAddress, amount, options)`
|
|
169
|
+
|
|
170
|
+
Withdraws funds from the confidential "available" balance back to the public layer (ERC20 tokens).
|
|
171
|
+
|
|
172
|
+
- **Parameters**:
|
|
173
|
+
- `signer` (ethers.Signer): The user's signer.
|
|
174
|
+
- `tokenAddress` (string): The token contract address.
|
|
175
|
+
- `amount` (number): The amount to withdraw.
|
|
176
|
+
- `options` (object, optional):
|
|
177
|
+
- `useOffchainVerify` (boolean): Use offchain verification. Default: `false`
|
|
178
|
+
- `waitForFinalization` (boolean): Wait for withdrawal finalization. Default: `true`
|
|
179
|
+
- **Returns**: A transaction receipt.
|
|
180
|
+
|
|
181
|
+
#### `waitForPendingBalance(address, privateKey, tokenAddress, options)`
|
|
182
|
+
|
|
183
|
+
Polls for pending balance to appear after a transfer (typically after another user calls `applyPending`).
|
|
184
|
+
|
|
185
|
+
- **Parameters**:
|
|
186
|
+
- `address` (string): The account address.
|
|
187
|
+
- `privateKey` (string): The private key for decryption.
|
|
188
|
+
- `tokenAddress` (string): The token contract address.
|
|
189
|
+
- `options` (object, optional):
|
|
190
|
+
- `maxAttempts` (number): Maximum polling attempts. Default: `60`
|
|
191
|
+
- `intervalMs` (number): Polling interval in milliseconds. Default: `3000`
|
|
192
|
+
- **Returns**: An object containing `amount` and `ciphertext`.
|
|
193
|
+
|
|
194
|
+
#### `getFeeAmount()`
|
|
195
|
+
|
|
196
|
+
Retrieves the current fee amount required for confidential transfers on the network.
|
|
197
|
+
|
|
198
|
+
- **Returns**: The fee amount in wei (bigint).
|
|
199
|
+
|
|
200
|
+
#### `getTokenBalance(address, tokenAddress)`
|
|
201
|
+
|
|
202
|
+
Retrieves the public ERC20 token balance for an address (non-confidential).
|
|
203
|
+
|
|
204
|
+
- **Parameters**:
|
|
205
|
+
- `address` (string): The account address.
|
|
206
|
+
- `tokenAddress` (string): The token contract address.
|
|
207
|
+
- **Returns**: The token balance (bigint).
|
|
208
|
+
|
|
209
|
+
### Examples
|
|
210
|
+
|
|
211
|
+
For a complete implementation demonstrating the full lifecycle of a confidential transaction—from deposit to withdrawal—please refer to the `examples/complete-flow.js` file included in this repository.
|
|
212
|
+
|
|
213
|
+
Additional examples are available in the `examples/` directory:
|
|
214
|
+
|
|
215
|
+
- **complete-flow.js**: Full workflow example covering all operations
|
|
216
|
+
- **simple-snippets.js**: Quick code snippets for common tasks
|
|
217
|
+
|
|
218
|
+
## Error Handling
|
|
219
|
+
|
|
220
|
+
The SDK provides descriptive error messages for common issues. Here are some typical scenarios:
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
try {
|
|
224
|
+
await client.transfer(signer, recipientAddress, tokenAddress, amount);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
if (error.message.includes("Insufficient balance")) {
|
|
227
|
+
console.error("Transfer amount exceeds available balance");
|
|
228
|
+
} else if (error.message.includes("Proof generation failed")) {
|
|
229
|
+
console.error("Failed to generate transfer proof");
|
|
230
|
+
} else if (error.message.includes("Account finalization timeout")) {
|
|
231
|
+
console.error("Account setup is still processing");
|
|
232
|
+
} else {
|
|
233
|
+
console.error("Transfer failed:", error.message);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Common Issues and Solutions
|
|
239
|
+
|
|
240
|
+
| Issue | Cause | Solution |
|
|
241
|
+
| :------------------------------- | :------------------------------------------------------ | :-------------------------------------------------- |
|
|
242
|
+
| "Account does not exist" | Recipient hasn't initialized their confidential account | Recipient must call `ensureAccount()` first |
|
|
243
|
+
| "Insufficient balance" | Transfer amount exceeds available confidential balance | Deposit more tokens or reduce transfer amount |
|
|
244
|
+
| "Insufficient fee token balance" | Not enough PathUSD on Tempo chain for fees | Top up fee token balance before transferring |
|
|
245
|
+
| "Account finalization timeout" | Account creation is still processing | Wait a few minutes and retry the operation |
|
|
246
|
+
| "Proof generation failed" | Invalid inputs or cryptographic operation error | Verify all parameters and ensure sufficient balance |
|
|
247
|
+
|
|
248
|
+
## Performance Metrics
|
|
249
|
+
|
|
250
|
+
The following are estimated execution times for standard operations within the confidential flow. Please note that these durations may vary based on network congestion and client hardware performance.
|
|
251
|
+
|
|
252
|
+
The following are estimated execution times for standard operations within the confidential flow. Please note that these durations may vary based on network congestion and client hardware performance.
|
|
253
|
+
|
|
254
|
+
| Operation | Avg Duration |
|
|
255
|
+
| :------------ | :----------- |
|
|
256
|
+
| Deposit | 63s |
|
|
257
|
+
| Transfer | 58s |
|
|
258
|
+
| Apply Pending | 61s |
|
|
259
|
+
| Withdraw | 58s |
|
|
260
|
+
|
|
261
|
+
## Security Considerations
|
|
262
|
+
|
|
263
|
+
When using the StableTrust SDK, follow these best practices to ensure the security of your confidential transactions:
|
|
264
|
+
|
|
265
|
+
1. **Private Key Management**
|
|
266
|
+
- Never expose or log private keys or seed phrases
|
|
267
|
+
- Store private keys securely (e.g., hardware wallets, encrypted vaults)
|
|
268
|
+
- Derived keys are sensitive cryptographic material—handle with care
|
|
269
|
+
|
|
270
|
+
2. **Signer Security**
|
|
271
|
+
- Use secure signer implementations (e.g., hardware wallets, encrypted key stores)
|
|
272
|
+
- Avoid using signers with exposed private keys in production
|
|
273
|
+
- Keep your ethers.js provider and signer in sync with your security setup
|
|
274
|
+
|
|
275
|
+
3. **Network Security**
|
|
276
|
+
- Use HTTPS-only RPC endpoints
|
|
277
|
+
- Verify contract addresses before initialization to prevent man-in-the-middle attacks
|
|
278
|
+
- Consider using dedicated RPC providers for production environments
|
|
279
|
+
|
|
280
|
+
4. **Account Initialization**
|
|
281
|
+
- Always call `ensureAccount()` before performing any confidential operations
|
|
282
|
+
- Verify that recipient accounts exist before transferring funds
|
|
283
|
+
- Allow sufficient time for account finalization before proceeding with operations
|
|
284
|
+
|
|
285
|
+
5. **Balance Verification**
|
|
286
|
+
- Check available balance before initiating transfers
|
|
287
|
+
- Be aware of transaction fees that may vary by network
|
|
288
|
+
- On Tempo chain, ensure sufficient PathUSD balance for fee payment
|
|
289
|
+
|
|
290
|
+
6. **Error Handling**
|
|
291
|
+
- Implement comprehensive error handling for all SDK operations
|
|
292
|
+
- Log errors appropriately without exposing sensitive information
|
|
293
|
+
- Implement retry logic for transient failures (network timeouts, etc.)
|
|
294
|
+
|
|
295
|
+
## Resources
|
|
296
|
+
|
|
297
|
+
- **Website**: [https://app.stabletrust.io/](https://app.stabletrust.io/)
|
|
298
|
+
- **Documentation**: [https://docs.fairblock.network/docs/confidential_transfers/confidential_transactions](https://docs.fairblock.network/docs/confidential_transfers/confidential_transactions)
|
|
299
|
+
- **Twitter**: [https://twitter.com/0xfairblock](https://twitter.com/0xfairblock)
|
|
300
|
+
- **GitHub**: [https://github.com/fairblock](https://github.com/fairblock)
|
|
301
|
+
|
|
302
|
+
## License
|
|
303
|
+
|
|
304
|
+
This package is licensed under the Apache-2.0 License. See the LICENSE file in the repository for details.
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fairblock/stabletrust",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for confidential transfers using homomorphic encryption and zero-knowledge proofs",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"import": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./wasm": "./pkg/confidential_transfer_proof_generation.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src/",
|
|
17
|
+
"pkg/",
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"confidential",
|
|
26
|
+
"transfers",
|
|
27
|
+
"zero-knowledge",
|
|
28
|
+
"encryption",
|
|
29
|
+
"blockchain",
|
|
30
|
+
"privacy"
|
|
31
|
+
],
|
|
32
|
+
"author": "",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"dotenv": "^17.2.3",
|
|
36
|
+
"ethers": "^6.16.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=16.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/pkg/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function generate_withdraw_proof(input: string): string;
|
|
4
|
+
export function decrypt_ciphertext(ciphertext_base64: string, keypair_base64: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate a deterministic ElGamal keypair from an EIP-712 signature
|
|
7
|
+
*/
|
|
8
|
+
export function generate_deterministic_keypair(signature_hex: string, domain_context: string): string;
|
|
9
|
+
export function test_wasm(): string;
|
|
10
|
+
export function generate_transfer_proof(input: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Decode transfer proof from contract input data and extract transfer amount ciphertext
|
|
13
|
+
* handle_index: 0 for sender, 1 for recipient
|
|
14
|
+
*/
|
|
15
|
+
export function decode_transfer_proof(validity_proof_base64: string, handle_index: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a random ElGamal keypair (for compatibility)
|
|
18
|
+
*/
|
|
19
|
+
export function generate_keypair(): string;
|
|
20
|
+
export function encrypt_amount(amount: bigint, pubkey_base64: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Generate a deterministic ElGamal keypair using legacy method (for backward compatibility)
|
|
23
|
+
*/
|
|
24
|
+
export function generate_deterministic_keypair_legacy(signature_hex: string): string;
|
|
25
|
+
|
|
26
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
27
|
+
|
|
28
|
+
export interface InitOutput {
|
|
29
|
+
readonly memory: WebAssembly.Memory;
|
|
30
|
+
readonly decode_transfer_proof: (a: number, b: number, c: number, d: number) => void;
|
|
31
|
+
readonly decrypt_ciphertext: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
32
|
+
readonly encrypt_amount: (a: number, b: bigint, c: number, d: number) => void;
|
|
33
|
+
readonly generate_deterministic_keypair: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
34
|
+
readonly generate_deterministic_keypair_legacy: (a: number, b: number, c: number) => void;
|
|
35
|
+
readonly generate_keypair: (a: number) => void;
|
|
36
|
+
readonly generate_transfer_proof: (a: number, b: number, c: number) => void;
|
|
37
|
+
readonly generate_withdraw_proof: (a: number, b: number, c: number) => void;
|
|
38
|
+
readonly test_wasm: (a: number) => void;
|
|
39
|
+
readonly __wbindgen_export_0: (a: number) => void;
|
|
40
|
+
readonly __wbindgen_export_1: (a: number, b: number) => number;
|
|
41
|
+
readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
|
|
42
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
43
|
+
readonly __wbindgen_export_3: (a: number, b: number, c: number) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
47
|
+
/**
|
|
48
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
49
|
+
* a precompiled `WebAssembly.Module`.
|
|
50
|
+
*
|
|
51
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
52
|
+
*
|
|
53
|
+
* @returns {InitOutput}
|
|
54
|
+
*/
|
|
55
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
59
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
60
|
+
*
|
|
61
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
62
|
+
*
|
|
63
|
+
* @returns {Promise<InitOutput>}
|
|
64
|
+
*/
|
|
65
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|