|
| 1 | +# Seal + Walrus Demo Application |
| 2 | + |
| 3 | +This Next.js application demonstrates the integration of Seal (decentralized secrets management) and Walrus (decentralized storage) to create a secure content platform. |
| 4 | + |
| 5 | +## Features Implemented |
| 6 | + |
| 7 | +### 1. **Encrypted Article Storage** |
| 8 | +- Articles are encrypted using Seal's Identity-Based Encryption (IBE) |
| 9 | +- Support for both text content and images |
| 10 | +- Images are encrypted separately and linked to articles |
| 11 | +- Encrypted data is stored on Walrus decentralized storage |
| 12 | +- Only the encrypted blob ID is stored locally |
| 13 | + |
| 14 | +### 2. **Access Control** |
| 15 | +- Public articles: Anyone can decrypt and read using demo allowlist |
| 16 | +- Restricted articles: Only allowlisted addresses can access |
| 17 | +- Admin functionality to create and manage allowlists |
| 18 | +- Demo allowlist pre-deployed for testing |
| 19 | + |
| 20 | +### 3. **Wallet Integration** |
| 21 | +- Connect with Sui wallets (Sui Wallet, Suiet, etc.) |
| 22 | +- Session key management for reduced wallet interactions |
| 23 | +- Personal message signing for authentication |
| 24 | + |
| 25 | +### 4. **Rich Content Support** |
| 26 | +- Text articles with titles and content |
| 27 | +- Optional image uploads (max 10MB) |
| 28 | +- Image preview before submission |
| 29 | +- Encrypted image storage and retrieval |
| 30 | + |
| 31 | +## Architecture |
| 32 | + |
| 33 | +### Data Flow |
| 34 | +1. **Writing Articles**: |
| 35 | + - User writes article content |
| 36 | + - Content is encrypted using Seal with a unique ID |
| 37 | + - Encrypted data is uploaded to Walrus |
| 38 | + - Metadata (blob ID, access info) stored locally |
| 39 | + |
| 40 | +2. **Reading Articles**: |
| 41 | + - Download encrypted data from Walrus |
| 42 | + - Create session key and get user signature |
| 43 | + - Build approval transaction for Move contract |
| 44 | + - Decrypt content using Seal client |
| 45 | + |
| 46 | +### Key Components |
| 47 | + |
| 48 | +- **WriteArticle**: Handles article creation and encryption |
| 49 | +- **ArticleList**: Displays articles and handles decryption |
| 50 | +- **AdminPanel**: Manages allowlists (admin only) |
| 51 | +- **seal.ts**: Seal encryption/decryption utilities |
| 52 | +- **storage.ts**: Local storage management |
| 53 | + |
| 54 | +## Setup Instructions |
| 55 | + |
| 56 | +1. **Move Contracts Already Deployed**: |
| 57 | + - Package ID: `0x9c2e3762ca1c5bd01f8adfc5de004e47bcc028441cdedb2c010a908e864233e8` |
| 58 | + - Demo Allowlist: `0xd7722daf6e0bdef36345ab97d7fb3e0e13d44aed7eeac06ac4bc72a6c6ea2a99` |
| 59 | + - All constants are pre-configured in `constants.ts` |
| 60 | + |
| 61 | +2. **Run the Application**: |
| 62 | + ```bash |
| 63 | + npm run dev |
| 64 | + ``` |
| 65 | + Access at http://localhost:3001 |
| 66 | + |
| 67 | +## Key Features |
| 68 | + |
| 69 | +### Payment System |
| 70 | +- **Article Posting Fee**: 1 SUI (1,000,000,000 MIST) per article |
| 71 | +- Fee is transferred to admin wallet on submission |
| 72 | +- Transaction must be signed before article encryption/upload |
| 73 | + |
| 74 | +### Transaction Flow |
| 75 | +1. User writes article and clicks submit |
| 76 | +2. Wallet prompts to sign transaction (1 SUI payment) |
| 77 | +3. Upon successful payment: |
| 78 | + - Article is encrypted using Seal |
| 79 | + - Encrypted data uploaded to Walrus |
| 80 | + - Metadata saved locally |
| 81 | +4. If transaction fails, no article is posted |
| 82 | + |
| 83 | +## Current Limitations |
| 84 | + |
| 85 | +1. **Allowlist Management**: Adding addresses to allowlist requires Cap object tracking (not fully implemented). |
| 86 | +2. **Public Access**: Uses a simplified approval mechanism for demo purposes. |
| 87 | +3. **Error Handling**: Basic error handling - production app would need more robust error management. |
| 88 | +4. **Local Storage**: Article metadata stored in browser localStorage - production would use a backend. |
| 89 | + |
| 90 | +## Security Considerations |
| 91 | + |
| 92 | +- Never expose master keys |
| 93 | +- Session keys have limited TTL (10 minutes) |
| 94 | +- Encrypted data is stored on Walrus, only metadata stored locally |
| 95 | +- Access control enforced by on-chain Move contracts |
| 96 | + |
| 97 | +## Next Steps |
| 98 | + |
| 99 | +1. Deploy and integrate actual Move contracts |
| 100 | +2. Implement subscription-based access control |
| 101 | +3. Add Cap object management for allowlist administration |
| 102 | +4. Implement server-side metadata storage |
| 103 | +5. Add support for multiple key server configurations |
0 commit comments