@rougechain/sdk 0.4.0 → 0.4.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 +44 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<strong>Build quantum-safe dApps on RougeChain</strong><br />
|
|
11
|
-
Transfers · DEX · NFTs · Bridge · Mail · Messenger
|
|
11
|
+
Transfers · DEX · NFTs · Shielded Transactions · Bridge · Mail · Messenger
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
@@ -58,7 +58,8 @@ const { balance } = await rc.getBalance(wallet.publicKey);
|
|
|
58
58
|
| **Staking** | `rc` | Stake/unstake XRGE for validation |
|
|
59
59
|
| **DEX** | `rc.dex` | AMM pools, swaps with slippage protection, liquidity |
|
|
60
60
|
| **NFTs** | `rc.nft` | RC-721 collections, mint, batch mint, royalties, freeze |
|
|
61
|
-
| **
|
|
61
|
+
| **Shielded** | `rc.shielded` | Private transfers with zk-STARK proofs, shield/unshield XRGE |
|
|
62
|
+
| **Bridge** | `rc.bridge` | ETH ↔ qETH, USDC ↔ qUSDC, XRGE bridge (Base Sepolia) |\r
|
|
62
63
|
| **Mail** | `rc.mail` | On-chain encrypted email (`@rouge.quant`) |
|
|
63
64
|
| **Messenger** | `rc.messenger` | E2E encrypted messaging with self-destruct |
|
|
64
65
|
|
|
@@ -306,6 +307,45 @@ const messages = await rc.messenger.getMessages(conversationId);
|
|
|
306
307
|
await rc.messenger.deleteMessage(messageId);
|
|
307
308
|
```
|
|
308
309
|
|
|
310
|
+
## Shielded Transactions (`rc.shielded`)
|
|
311
|
+
|
|
312
|
+
Private value transfers using zk-STARK proofs. Shield XRGE into private notes, transfer privately, and unshield back to public balance.
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
import { createShieldedNote, computeCommitment, computeNullifier } from "@rougechain/sdk";
|
|
316
|
+
|
|
317
|
+
// Shield 100 XRGE into a private note
|
|
318
|
+
const { note } = await rc.shielded.shield(wallet, { amount: 100 });
|
|
319
|
+
// ⚠️ Save `note` securely — losing it means losing the funds!
|
|
320
|
+
// note = { commitment, nullifier, value, randomness, ownerPubKey }
|
|
321
|
+
|
|
322
|
+
// Check pool stats
|
|
323
|
+
const stats = await rc.shielded.getStats();
|
|
324
|
+
// { commitment_count, nullifier_count, active_notes }
|
|
325
|
+
|
|
326
|
+
// Check if a nullifier has been spent
|
|
327
|
+
const { spent } = await rc.shielded.isNullifierSpent(note.nullifier);
|
|
328
|
+
|
|
329
|
+
// Private transfer (requires STARK proof from Rust prover)
|
|
330
|
+
await rc.shielded.transfer(wallet, {
|
|
331
|
+
nullifiers: [note.nullifier],
|
|
332
|
+
outputCommitments: [recipientCommitment],
|
|
333
|
+
proof: starkProofHex,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Unshield back to public balance
|
|
337
|
+
await rc.shielded.unshield(wallet, {
|
|
338
|
+
nullifiers: [note.nullifier],
|
|
339
|
+
amount: 100,
|
|
340
|
+
proof: starkProofHex,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Client-side crypto primitives
|
|
344
|
+
const randomness = generateRandomness();
|
|
345
|
+
const commitment = computeCommitment(100, wallet.publicKey, randomness);
|
|
346
|
+
const nullifier = computeNullifier(randomness, commitment);
|
|
347
|
+
```
|
|
348
|
+
|
|
309
349
|
## Low-Level Signing
|
|
310
350
|
|
|
311
351
|
For advanced use cases:
|
|
@@ -347,6 +387,8 @@ import type {
|
|
|
347
387
|
NftToken, LiquidityPool, BalanceResponse, Validator,
|
|
348
388
|
BridgeConfig, MailMessage, MessengerMessage, WalletKeys,
|
|
349
389
|
PriceSnapshot, PoolEvent, PoolStats, SwapQuote,
|
|
390
|
+
ShieldParams, ShieldedTransferParams, UnshieldParams, ShieldedStats,
|
|
391
|
+
ShieldedNote,
|
|
350
392
|
} from "@rougechain/sdk";
|
|
351
393
|
```
|
|
352
394
|
|