diff --git a/docs/workshops/README.md b/docs/workshops/README.md new file mode 100644 index 0000000..381726f --- /dev/null +++ b/docs/workshops/README.md @@ -0,0 +1,612 @@ +# PrivacyLayer Developer Workshops + +Comprehensive workshop curriculum for building privacy-preserving applications with PrivacyLayer. + +--- + +## Workshop Series Overview + +| Workshop | Title | Duration | Level | +|----------|-------|----------|-------| +| 1 | Introduction to Privacy-Preserving Development | 2 hours | Beginner | +| 2 | Building with PrivacyLayer SDK | 3 hours | Intermediate | +| 3 | Advanced ZK Circuit Development | 3 hours | Advanced | + +--- + +## Workshop 1: Introduction to Privacy-Preserving Development + +### Duration: 2 hours +### Level: Beginner +### Prerequisites: Basic programming knowledge + +### Learning Objectives +By the end of this workshop, participants will be able to: +- Understand the importance of privacy in Web3 +- Explain how zero-knowledge proofs work +- Set up a basic PrivacyLayer development environment +- Create their first private transaction + +### Curriculum + +#### Part 1: Why Privacy Matters (30 minutes) + +**Slides:** +1. The Privacy Problem in Public Blockchains + - Transaction transparency + - Real-world privacy risks + - Case studies: Privacy failures + +2. Privacy vs. Anonymity + - Definitions and differences + - Regulatory landscape + - Privacy as a feature + +3. Zero-Knowledge Proofs Introduction + - The magic cave analogy + - Properties: Completeness, Soundness, Zero-Knowledge + - Real-world applications + +**Interactive Element:** Privacy Quiz +- Participants answer questions about privacy scenarios +- Real-time polling and discussion + +#### Part 2: PrivacyLayer Architecture (30 minutes) + +**Slides:** +1. System Overview + - Components: Smart contracts, SDK, dApp + - Transaction flow + - Security model + +2. Core Concepts + - Privacy pools + - Commitments and nullifiers + - Merkle trees + +3. Stellar Integration + - Soroban smart contracts + - Freighter wallet + - Transaction fees + +**Live Demo:** +- Walk through a deposit/withdrawal on testnet +- Show transaction on Stellar Expert + +#### Part 3: Hands-on Setup (45 minutes) + +**Exercise 1: Environment Setup** +```bash +# Install dependencies +npm install @privacylayer/sdk + +# Clone workshop repository +git clone https://github.com/PrivacyLayer/workshop-starter + +# Install Freighter wallet extension +# https://freighter.app +``` + +**Exercise 2: First Deposit** +```typescript +import { PrivacyLayer } from '@privacylayer/sdk'; + +// Initialize client +const client = new PrivacyLayer({ + network: 'testnet', + wallet: freighterWallet +}); + +// Connect wallet +await client.connect(); + +// Deposit funds +const note = await client.deposit({ + amount: '10', // XLM + asset: 'XLM' +}); + +console.log('Deposit note:', note); +// IMPORTANT: Save this note securely! +``` + +**Exercise 3: First Withdrawal** +```typescript +// Withdraw using your saved note +const tx = await client.withdraw({ + note: savedNote, + recipientAddress: 'G...', // Fresh address +}); + +console.log('Withdrawal complete:', tx.hash); +``` + +#### Part 4: Q&A and Wrap-up (15 minutes) + +- Review key concepts +- Answer questions +- Homework assignment: Complete a private transaction + +### Materials Provided +- Slide deck (PDF and Google Slides) +- Code repository with exercises +- Cheat sheet for common commands +- Recording (posted after workshop) + +--- + +## Workshop 2: Building with PrivacyLayer SDK + +### Duration: 3 hours +### Level: Intermediate +### Prerequisites: Workshop 1 or equivalent knowledge, JavaScript/TypeScript proficiency + +### Learning Objectives +- Build a complete privacy-enabled application +- Handle deposits, withdrawals, and balance queries +- Implement proper security practices +- Integrate PrivacyLayer into existing applications + +### Curriculum + +#### Part 1: SDK Deep Dive (45 minutes) + +**Topics:** +1. SDK Architecture + - Module structure + - Configuration options + - Error handling + +2. Core Methods + - `deposit()` - Add funds to pool + - `withdraw()` - Private withdrawal + - `getBalance()` - Check privacy balance + - `getAnonymitySet()` - View pool statistics + +3. Event Handling + - Transaction events + - Pool updates + - Error events + +**Code Example:** +```typescript +// Full SDK initialization +import { PrivacyLayer, WalletType } from '@privacylayer/sdk'; + +const client = new PrivacyLayer({ + network: 'mainnet', + wallet: { + type: WalletType.Freighter, + }, + options: { + pollingInterval: 5000, + maxRetries: 3, + } +}); + +// Event listeners +client.on('deposit:confirmed', (event) => { + console.log('Deposit confirmed:', event); +}); + +client.on('withdrawal:complete', (event) => { + console.log('Withdrawal complete:', event); +}); + +await client.connect(); +``` + +#### Part 2: Building a Privacy-Enabled DApp (90 minutes) + +**Project: Private Payment Gateway** + +**Step 1: Project Setup (15 minutes)** +```bash +# Create Next.js project +npx create-next-app private-payments + +# Install dependencies +npm install @privacylayer/sdk stellar-sdk @stellar/freighter-api +``` + +**Step 2: SDK Integration (30 minutes)** +```typescript +// lib/privacy.ts +import { PrivacyLayer } from '@privacylayer/sdk'; + +export const createClient = async () => { + const client = new PrivacyLayer({ + network: process.env.NEXT_PUBLIC_NETWORK as 'testnet' | 'mainnet', + wallet: { type: 'freighter' } + }); + + await client.connect(); + return client; +}; +``` + +**Step 3: Deposit Component (20 minutes)** +```tsx +// components/DepositForm.tsx +import { useState } from 'react'; +import { usePrivacyClient } from '../hooks/usePrivacyClient'; + +export function DepositForm() { + const [amount, setAmount] = useState(''); + const [note, setNote] = useState(''); + const client = usePrivacyClient(); + + const handleDeposit = async () => { + const result = await client.deposit({ + amount, + asset: 'XLM' + }); + setNote(result.note); + alert('Save this note securely!'); + }; + + return ( +
+ setAmount(e.target.value)} + placeholder="Amount in XLM" + /> + + {note && ( +
+ Save this note: {note} +
+ )} +
+ ); +} +``` + +**Step 4: Withdrawal Component (25 minutes)** +```tsx +// components/WithdrawForm.tsx +import { useState } from 'react'; +import { usePrivacyClient } from '../hooks/usePrivacyClient'; + +export function WithdrawForm() { + const [note, setNote] = useState(''); + const [recipient, setRecipient] = useState(''); + const client = usePrivacyClient(); + + const handleWithdraw = async () => { + try { + const tx = await client.withdraw({ + note, + recipientAddress: recipient + }); + alert(`Withdrawal complete: ${tx.hash}`); + } catch (error) { + alert(`Error: ${error.message}`); + } + }; + + return ( +
+