|
| 1 | +<!-- |
| 2 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
| 3 | +Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> |
| 4 | +--> |
| 5 | +# Building libstamp |
| 6 | + |
| 7 | +## Current Status |
| 8 | + |
| 9 | +**Core Idris2 types**: ✓ Complete (`src/abi/`) |
| 10 | +**Zig FFI implementation**: ✓ Complete (`ffi/zig/`) |
| 11 | +**Build system**: ⚠️ Zig version compatibility issue |
| 12 | + |
| 13 | +## The Zig Version Issue |
| 14 | + |
| 15 | +The FFI code is written for **Zig 0.13.0**, but your system has **Zig 0.15.2** installed. |
| 16 | + |
| 17 | +Zig 0.15 is a development version with breaking API changes. The build system API is completely different. |
| 18 | + |
| 19 | +## Option 1: Downgrade to Zig 0.13.0 (Recommended) |
| 20 | + |
| 21 | +```bash |
| 22 | +# You have asdf installed, so: |
| 23 | +asdf install zig 0.13.0 |
| 24 | +cd ~/Documents/hyperpolymath-repos/libstamp |
| 25 | +asdf local zig 0.13.0 |
| 26 | + |
| 27 | +# Now build works: |
| 28 | +cd ffi/zig |
| 29 | +zig build # Build library |
| 30 | +zig build test # Run tests |
| 31 | +zig build example # Run example |
| 32 | +``` |
| 33 | + |
| 34 | +## Option 2: Skip FFI for MVP |
| 35 | + |
| 36 | +For the **Telegram bot demo** (your Week 1 goal), you don't actually need the full FFI yet. |
| 37 | + |
| 38 | +**What you can do instead:** |
| 39 | + |
| 40 | +1. **Mock the verification functions** in TypeScript/ReScript |
| 41 | +2. Build the Telegram bot with mocked verification |
| 42 | +3. Prove the UX works |
| 43 | +4. Come back and integrate real FFI later |
| 44 | + |
| 45 | +This gets you to a working demo **faster**. |
| 46 | + |
| 47 | +### Mock Implementation (TypeScript for Deno) |
| 48 | + |
| 49 | +```typescript |
| 50 | +// mock-stamp.ts - Temporary until Zig FFI is built |
| 51 | + |
| 52 | +export interface UnsubscribeParams { |
| 53 | + url: string; |
| 54 | + tested_at: number; |
| 55 | + response_code: number; |
| 56 | + response_time: number; |
| 57 | + token: string; |
| 58 | + signature: string; |
| 59 | +} |
| 60 | + |
| 61 | +export function verifyUnsubscribe(params: UnsubscribeParams): boolean { |
| 62 | + // Mock implementation - checks basic properties |
| 63 | + if (!params.url.startsWith('https://')) return false; |
| 64 | + if (params.response_code !== 200) return false; |
| 65 | + if (params.response_time >= 200) return false; |
| 66 | + |
| 67 | + const now = Date.now(); |
| 68 | + const age = now - params.tested_at; |
| 69 | + if (age > 60000) return false; // > 60 seconds old |
| 70 | + |
| 71 | + return true; |
| 72 | +} |
| 73 | + |
| 74 | +export function generateProof(params: UnsubscribeParams): string { |
| 75 | + return JSON.stringify({ |
| 76 | + type: "unsubscribe_verification", |
| 77 | + url: params.url, |
| 78 | + tested_at: params.tested_at, |
| 79 | + response_code: params.response_code, |
| 80 | + response_time_ms: params.response_time, |
| 81 | + verified: true, |
| 82 | + timestamp: Date.now(), |
| 83 | + }, null, 2); |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +This lets you: |
| 88 | +- ✓ Build Telegram bot **now** |
| 89 | +- ✓ Demo the UX **this week** |
| 90 | +- ✓ Show investors/users |
| 91 | +- → Add real FFI later (Week 2-3) |
| 92 | + |
| 93 | +## Option 3: Update build.zig for Zig 0.15 |
| 94 | + |
| 95 | +If you want to use Zig 0.15, I can research the new API and update `build.zig`. But this will take time. |
| 96 | + |
| 97 | +## My Recommendation |
| 98 | + |
| 99 | +**For Week 1 (this week):** |
| 100 | +- Use **Option 2** (mock implementation) |
| 101 | +- Build Telegram bot with mocked verification |
| 102 | +- Get feedback from users |
| 103 | + |
| 104 | +**For Week 2:** |
| 105 | +- Install Zig 0.13.0 (Option 1) |
| 106 | +- Build real FFI |
| 107 | +- Replace mocks with real verification |
| 108 | + |
| 109 | +**Why:** Gets you to a demo **faster**. The UX is more important than the implementation for early feedback. |
| 110 | + |
| 111 | +## Next Steps |
| 112 | + |
| 113 | +Tell me which option you want: |
| 114 | + |
| 115 | +1. **"Help me downgrade Zig"** → I'll guide you through asdf setup |
| 116 | +2. **"Let's use mocks for now"** → I'll help you build the Telegram bot immediately |
| 117 | +3. **"Fix build.zig for 0.15"** → I'll research and update (takes longer) |
| 118 | + |
| 119 | +What's your priority? |
0 commit comments