Skip to content

chore: merge poulpy-js repo into squid monorepo#27

Merged
cedoor merged 1 commit into
mainfrom
refactor/merge-js-repo
Apr 22, 2026
Merged

chore: merge poulpy-js repo into squid monorepo#27
cedoor merged 1 commit into
mainfrom
refactor/merge-js-repo

Conversation

@cedoor
Copy link
Copy Markdown
Owner

@cedoor cedoor commented Apr 22, 2026

Summary by CodeRabbit

  • New Features

    • JavaScript bindings for browser and Node.js environments enabling homomorphic encryption operations
    • Interactive demo application showcasing end-to-end FHE workflows
    • End-to-end testing with automated CI pipeline
  • Documentation

    • Updated README with monorepo structure and project overview
  • Chores

    • Configured project as a Cargo + pnpm workspace with improved dependency management
    • Enhanced build tooling and CI/CD automation

@cedoor cedoor merged commit 0426dc2 into main Apr 22, 2026
2 of 3 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 998e8870-68b2-4a74-98d9-747ab4e24384

📥 Commits

Reviewing files that changed from the base of the PR and between 8b97f72 and 1560a91.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • crates/squid/Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (76)
  • .cursor/rules/constraints.mdc
  • .cursor/rules/conventions.mdc
  • .cursor/rules/modules.mdc
  • .cursor/rules/poulpy-concepts.mdc
  • .cursor/rules/project.mdc
  • .github/workflows/ci.yml
  • .gitignore
  • Cargo.toml
  • README.md
  • crates/squid-napi/Cargo.toml
  • crates/squid-napi/build.rs
  • crates/squid-napi/src/lib.rs
  • crates/squid-wasm/Cargo.toml
  • crates/squid-wasm/src/lib.rs
  • crates/squid/Cargo.toml
  • crates/squid/examples/add_u32.rs
  • crates/squid/src/backend.rs
  • crates/squid/src/ciphertext.rs
  • crates/squid/src/context.rs
  • crates/squid/src/keys.rs
  • crates/squid/src/lib.rs
  • crates/squid/src/scratch.rs
  • crates/squid/tests/bdd_parallel.rs
  • crates/squid/tests/ciphertext_serialization.rs
  • crates/squid/tests/common/mod.rs
  • crates/squid/tests/evaluation_key_serialization.rs
  • crates/squid/tests/keygen_seeds.rs
  • demo/next-env.d.ts
  • demo/next.config.ts
  • demo/package.json
  • demo/scripts/ensure-demo-ek.mjs
  • demo/scripts/generate-demo-ek.mjs
  • demo/src/app/api/add/route.ts
  • demo/src/app/globals.css
  • demo/src/app/layout.tsx
  • demo/src/app/page.tsx
  • demo/src/components/Demo.tsx
  • demo/src/components/DemoLoader.tsx
  • demo/src/components/atoms/Btn.tsx
  • demo/src/components/atoms/ByteViewer.tsx
  • demo/src/components/atoms/Card.tsx
  • demo/src/components/atoms/Chip.tsx
  • demo/src/components/atoms/Fingerprint.tsx
  • demo/src/components/atoms/NoiseMeter.tsx
  • demo/src/components/atoms/NumberPad.tsx
  • demo/src/components/atoms/StepHeader.tsx
  • demo/src/components/atoms/StripePlaceholder.tsx
  • demo/src/components/mascot/Poulpy.tsx
  • demo/src/components/steps/Step1Keygen.tsx
  • demo/src/components/steps/Step2Encrypt.tsx
  • demo/src/components/steps/Step3Evaluate.tsx
  • demo/src/components/steps/Step4Decrypt.tsx
  • demo/src/components/terminal/ServerTerminal.tsx
  • demo/src/hooks/useFhe.ts
  • demo/src/lib/demo-seed.ts
  • demo/src/lib/fhe-types.ts
  • demo/src/lib/fingerprint.ts
  • demo/src/lib/load-demo-evaluator.ts
  • demo/src/lib/pack.ts
  • demo/tsconfig.json
  • demo/vercel.json
  • package.json
  • packages/squid-js/README.md
  • packages/squid-js/build-linux-napi.Dockerfile
  • packages/squid-js/package.json
  • packages/squid-js/scripts/build-linux-napi.sh
  • packages/squid-js/src/client.ts
  • packages/squid-js/src/server-browser-stub.ts
  • packages/squid-js/src/server.ts
  • packages/squid-js/src/squid-worker.ts
  • packages/squid-js/tsconfig.json
  • pnpm-workspace.yaml
  • tests/index.spec.ts
  • tests/package.json
  • tests/playwright.config.ts
  • tests/tsconfig.json

📝 Walkthrough

Walkthrough

This PR restructures the project from a single Rust crate into a monorepo with a Cargo workspace (crates/squid, crates/squid-wasm, crates/squid-napi) and a pnpm workspace. It adds WebAssembly and Node.js N-API bindings, a comprehensive Next.js demo application with FHE encryption workflow UI, and E2E testing infrastructure with Playwright.

Changes

Cohort / File(s) Summary
Cursor Documentation Rules
.cursor/rules/constraints.mdc, .cursor/rules/conventions.mdc, .cursor/rules/modules.mdc, .cursor/rules/poulpy-concepts.mdc, .cursor/rules/project.mdc
Updated rule scopes and paths from src/ to crates/squid/src/. Added monorepo layout documentation and reformatted tables without changing content.
Workspace Configuration
Cargo.toml, package.json, pnpm-workspace.yaml, .gitignore, README.md
Converted root Cargo.toml to workspace format containing crates/squid, squid-wasm, squid-napi. Added root package.json with pnpm workspace scripts. Extended .gitignore for Node/WASM/demo artifacts. Updated README to describe monorepo and client/server architecture.
Rust Crates
crates/squid/Cargo.toml, crates/squid-wasm/Cargo.toml, crates/squid-wasm/src/lib.rs, crates/squid-napi/Cargo.toml, crates/squid-napi/build.rs, crates/squid-napi/src/lib.rs
Added squid-wasm crate with wasm-bindgen exports (Session, keygen, encrypt/decrypt). Added squid-napi crate with N-API bindings for server-side Evaluator (load, addU32). Configured both as cdylib with workspace dependency on squid core.
JavaScript Package
packages/squid-js/package.json, packages/squid-js/tsconfig.json, packages/squid-js/src/client.ts, packages/squid-js/src/server.ts, packages/squid-js/src/server-browser-stub.ts, packages/squid-js/src/squid-worker.ts, packages/squid-js/README.md, packages/squid-js/build-*.*.Dockerfile, packages/squid-js/scripts/build-linux-napi.sh
Created unified squid-js package exporting browser client and Node server with conditional imports. Client uses Worker-backed WASM Session for off-thread crypto. Server re-exports N-API Evaluator. Included Docker build setup for Linux N-API artifact generation.
Demo Application - Configuration
demo/package.json, demo/next.config.ts, demo/next-env.d.ts, demo/tsconfig.json, demo/vercel.json
Set up Next.js 15 app with CORS headers, wasm async support, and serverExternalPackages config. Added scripts for deterministic demo EK generation. Included Vercel deployment config.
Demo Application - Backend
demo/src/app/layout.tsx, demo/src/app/page.tsx, demo/src/app/api/add/route.ts, demo/scripts/ensure-demo-ek.mjs, demo/scripts/generate-demo-ek.mjs
Implemented root layout with fonts and global styles. Created API route /api/add for homomorphic addition using server-side N-API Evaluator. Added scripts to generate/cache demo evaluation key deterministically.
Demo Application - Frontend Components
demo/src/components/Demo.tsx, demo/src/components/DemoLoader.tsx, demo/src/components/atoms/*, demo/src/components/steps/Step*.tsx, demo/src/components/mascot/Poulpy.tsx, demo/src/components/terminal/ServerTerminal.tsx
Built interactive FHE demo UI with step-by-step flow (keygen → encrypt → evaluate → decrypt). Created reusable atoms (Btn, Card, Chip, ByteViewer, NumberPad, Fingerprint, NoiseMeter). Animated mascot (Poulpy) reacts to state. Server terminal displays live logs.
Demo Application - Hooks & Utilities
demo/src/hooks/useFhe.ts, demo/src/lib/fhe-types.ts, demo/src/lib/fingerprint.ts, demo/src/lib/pack.ts, demo/src/lib/demo-seed.ts, demo/src/lib/load-demo-evaluator.ts, demo/src/app/globals.css
Defined FHE state machine and action handlers (keygen, encrypt, evaluate, decrypt). Implemented deterministic fingerprinting and noise computation from ciphertext bytes. Created helpers for packing/unpacking ciphertexts and formatting bytes. Added comprehensive global CSS with design tokens, animations, and responsive grid layout.
Testing Infrastructure
tests/package.json, tests/playwright.config.ts, tests/tsconfig.json, tests/index.spec.ts, .github/workflows/ci.yml
Added Playwright E2E test package with test config (single worker, 120s timeout). Implemented test automating full FHE workflow (keygen → encrypt → evaluate → decrypt). Added CI job running E2E tests with Node setup, Rust nightly, wasm-pack, pnpm, and Playwright caching.

Sequence Diagram

sequenceDiagram
    participant Browser as Browser (Demo UI)
    participant Worker as Web Worker (WASM)
    participant NextAPI as Next.js API
    participant Server as Node Server (N-API)
    
    Browser->>Browser: Step 1: Initialize
    Browser->>Worker: Create Session (keygen)
    Worker->>Worker: Generate SK/EK from seeds
    Worker-->>Browser: Return EK bytes
    Browser->>Browser: Display SK preview
    
    Browser->>Browser: Step 2: Select inputs (a, b)
    Browser->>Worker: Encrypt a, b
    Worker->>Worker: Encrypt with SK
    Worker-->>Browser: Return ctA, ctB
    Browser->>Browser: Display ciphertexts
    
    Browser->>Browser: Step 3: Send for evaluation
    Browser->>NextAPI: POST /api/add (ctA, ctB)
    NextAPI->>Server: Load Evaluator with EK
    Server->>Server: Perform homomorphic addition
    Server-->>NextAPI: Return ctSum
    NextAPI-->>Browser: Return ctSum
    Browser->>Browser: Display result ciphertext
    
    Browser->>Browser: Step 4: Decrypt
    Browser->>Worker: Decrypt ctSum
    Worker->>Worker: Decrypt with SK
    Worker-->>Browser: Return plaintext result
    Browser->>Browser: Display result (a+b)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 A monorepo's born, with bindings in place,
WASM and Node in one shared space,
Demo delights with FHE magic shown,
From keys to sums, a journey well-sown,
Squid hops through workflows with speed and with grace!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/merge-js-repo

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant