About
## Wave 1 submission
Deliverable GitHub: https://github.com/vwakesahu/fhe-giftcards
Live on Base Sepolia: full end-to-end private checkout flow running on testnet with real transactions.
What We Built
A complete private gift card checkout system using Fhenix CoFHE (Fully Homomorphic Encryption) on Base Sepolia. A buyer places an encrypted order on-chain, an observer fulfills it by purchasing a real gift card from Reloadly's API, and the gift card code is delivered back to the buyer through hybrid encryption, nobody else can read it.
Architecture: Hybrid Encryption (FHE + AES + IPFS)
The core innovation is a hybrid encryption scheme that combines three technologies: FHE (Fhenix CoFHE) handles on-chain access control. Product ID and amount are stored as euint64 encrypted values, only the assigned observer can decrypt them. The AES decryption key is stored as euint128, only the buyer can decrypt it. Access is enforced at the protocol level via FHE.allow(handle, address).
AES-128-GCM encrypts the actual gift card code. This removes any length limitation, codes of any size work. The observer generates a random 128-bit key, encrypts the code, and the key goes on-chain via FHE while the ciphertext goes to IPFS.
IPFS (Pinata) stores the AES-encrypted payload. The IPFS CID is stored on-chain in the contract and is publicly visible, but the data at that CID is AES ciphertext, completely useless without the FHE-protected key.
Smart Contract: PrivateCheckout.sol
Deployed on Base Sepolia: https://sepolia.basescan.org/address/0xFD80E75d552c715A50B2D258D557dc732Ff59b43#code
Stores per-order:
euint64 encProductId — what to buy (FHE-encrypted, observer-decryptable) euint64 encAmount — denomination (FHE-encrypted, observer-decryptable) euint128 encAesKey — AES key for the gift card code (FHE-encrypted, buyer-only) string ipfsCid — pointer to AES-encrypted gift card code on IPFS Observer bonding (0.01 ETH), 10-minute deadline, 50% bond slashing on failure Scripts e2e.ts — single-command demo that deploys, registers, places order, buys gift card from Reloadly sandbox, encrypts with AES, uploads to IPFS, FHE-encrypts AES key, fulfills on-chain, buyer decrypts everything. Outputs Basescan tx links and IPFS links. observer.ts — standalone listener that watches for OrderPlaced events and fulfills orders automatically. demo.ts — buyer-side script for the two-terminal flow. crypto.ts — AES-128-GCM encrypt/decrypt helpers. ipfs.ts — Pinata upload/fetch with public gateway fallback. giftcard.ts — Reloadly sandbox API integration (free $1000 test balance, returns fake codes). Test Suite 16 tests passing on local mock FHE environment covering: observer registration, encrypted order placement, fulfillment with ETH transfer, buyer decryption via mocks, access control (non-observer/non-buyer rejections), double-fulfill revert, deadline enforcement, refund with bond slashing.
## Wave 2 submission
1. A real dApp on the Fhenix SDK. Built a Next.js 16 frontend at https://app.sigill.store that uses cofhejs directly in the browser. Four routes:
/ shows orders by scanning OrderPlaced events filtered to the connected wallet. /buy is a three-step wizard (product, observer, confirm) that encrypts the product ID via cofhejs.encrypt, sets an encrypted cUSDC allowance on Sigill, then calls placeOrder. /wrap is the balances panel. Mint faucet, wrap USDC into cUSDC, unwrap cUSDC back to USDC, reveal-on-click sealed balance via cofhejs.unseal. /order/[id] is the sealed envelope. Clicking "Open envelope" unseals the FHE-wrapped AES key, pulls the AES ciphertext from IPFS, and decrypts the gift-card code locally. 2. Confidential token wrapper (cUSDC). Added ConfidentialERC20.sol, an ERC-7984-style wrapper over MockUSDC. Encrypted balances (euint64 handles), encrypted transfer / approve / transferFrom with silent clamping on insufficient funds. Also added a non-standard transferFromAllowance so the Sigill escrow can pull the buyer's already-set encrypted allowance without re-passing an InEuint64 through a nested msg.sender (which would break the zkv signature binding). This closes the privacy gap from Wave 1: the payment amount itself is now encrypted, not plain ETH in escrow.
- Standalone observer daemon. New @sigill/observer package. A stateless TypeScript process that polls OrderPlaced on Sigill and UnwrapRequested on cUSDC every 5 seconds, unseals what needs unsealing via cofhejs/node, purchases from Reloadly sandbox, hybrid-encrypts the code onto IPFS, and fulfils or honestly rejects. Also ships a pnpm unwrap CLI for operator cash-out. Restart-safe because the chain is the dedupe layer, no database.
- Decentralisation design doc. Full write-up of how to move from one trusted observer to a marketplace of bonded relays with reputation, at https://github.com/vwakesahu/fhe-giftcards/blob/main/docs/Decentralized%20Observer%20System.md
Links:
Landing: https://www.sigill.store/
App: https://app.sigill.store/ Repo: https://github.com/vwakesahu/fhe-giftcards Submission write-up: https://github.com/vwakesahu/fhe-giftcards/blob/main/docs/wave-2-submission.md Decentralisation design: https://github.com/vwakesahu/fhe-giftcards/blob/main/docs/Decentralized%20Observer%20System.md Sigill contract: https://sepolia.basescan.org/address/0x22C541Bf843113e7C04ab9648eC8735a3feba1dC cUSDC (ConfidentialERC20): https://sepolia.basescan.org/address/0x2C838637BB71c565EB0ccb0e73569E323E1F2c2D MockUSDC: https://sepolia.basescan.org/address/0xE29D70400026d77a790a8E483168B94D6E36424F
## Wave 3 submission
- Multi-observer runtime (shipped). New Observer.sol abstract base owns the registry, per-observer slot capacity, FIFO queue, and on-chain success-rate accounting. placeOrder now emits OrderInProccessed (slotted) or OrderInQueued (waitlisted); queued orders auto-promote when the head clears. App's "Pick relay" step reads the live roster from getObserverDetail() instead of a hardcoded list.
- Fee model (design draft), on-chain in Wave 4. Working proposal at https://github.com/vwakesahu/fhe-giftcards/blob/main/docs/fee-model.md, protocol fee (fixed + bps) plus observer-set markup published on-chain at registration, with worked examples for $5/$25/$100 cards. Held back from contract integration to iterate on the model first.
## Wave 4 submission
Wave 4 transforms the multi-observer registry introduced in Wave 3 into a functioning market, while eliminating the remaining tampering vector left unresolved in the previous wave
Shipped:
- Two-step, tamper-resistant checkout. `placeOrder` is replaced by `quoteOrder` + `confirmOrder`. The contract computes the encrypted total (price + observerFee + 0.25% platformFee) inside `quoteOrder`. The buyer unseals it locally, re-encrypts as the cUSDC approve amount, then confirms. `confirmOrder` pulls the allowance and FHE.eq-verifies it against the stored quote. Mismatch silently zeros escrow and refunds in-place in the same tx. The buyer cannot tamper because the comparison value is contract-computed.
- Per-observer commission market. Each observer publishes a flat fee at registration (`registerObserver(uint64 fees)`) and updates it any time via `setObserverFees`. Fees are plaintext on-chain so the dApp's relay picker renders them directly. Observers compete on price and reliability; buyers route on whichever tradeoff they want.
- Platform fee and treasury split. A 0.25% protocol fee splits off at `fulfillOrder` via two encrypted transfers (observer gets `encPaid - platformFee`, treasury gets `platformFee`), no-ops if escrow was zeroed by the FHE.eq mismatch path.
dApp additions:
- Confirm step itemises card price, relay fee, platform fee, and total to pay. - Pre-flight balance check: the wizard decrypts the buyer's own sealed balance against the unsealed quote total and bails with a clear "wrap N more USDC" message before any approve tx fires. - Order detail has an Unseal action that decrypts `encPaid` locally to reveal the actual cUSDC paid.
Live on Base Sepolia:
- App: https://app.sigill.store - Landing: https://www.sigill.store - Sigill: https://sepolia.basescan.org/address/0x0dED2B81A0463e6af64110d637CADda4545D8470 - cUSDC: https://sepolia.basescan.org/address/0x93Db1E63315463bA6A25918820959d1086c50E06 - Wave 4 walkthrough video: https://youtu.be/W8zUIEEb8uo
Repo: https://github.com/vwakesahu/fhe-giftcards
Did not ship this wave, planning written up for Wave 5: success-rate math fix, reputation-weighted ranking, slashing-to-buyer compensation, bond-to-max-order-size scaling. Design doc: https://github.com/vwakesahu/fhe-giftcards/blob/main/docs/reputation-and-slashing.md
## Wave 5 submission
Wave 5 updates
- Real Apple gift cards delivered end-to-end. Observer now routes through Reloadly production (gated behind RELOADLY_ENV=live) with separate live credentials, and PRODUCT_MAP_LIVE[1] points at Reloadly product 21 (App Store & iTunes US, $2 range). The full path is proven: on-chain quoteOrder → encrypted approve → confirmOrder → observer decrypt → Reloadly live order → real Apple code pinned to IPFS → buyer unseals AES key.
- Multi-brand catalog with App Store live, seven coming-soon. Picker now carries App Store & iTunes, Netflix, Spotify, Google Play, Xbox Live, PlayStation, Steam, Roblox. Only App Store is on-chain (productActive[1]); the rest render with brand logos, a "Coming soon" pill in place of the price, lower opacity, disabled state, and a defensive wizard guard that bails before quoteOrder if a coming-soon product somehow gets selected.
- Reloadly live-test script (packages/observer/scripts/reloadly-live-test.mjs): discovery + sequence-buy against production with persistent receipts in reloadly-receipts/live-test.log so issued card codes are never lost across crashes or process restarts.
- Vault cash-out scripts (packages/contracts/scripts/query-vault-balance.mjs + unwrap-vault.mjs): read-only balance estimator that nets deposits against past unwrap claims, plus a Safe-driven unwrap path that builds + signs the multi-sig transaction (2-of-3) to pull plaintext USDC out of the protocol vault.
- Fresh deploy on Base Sepolia:
- Sigill: 0x34F62D4B05631a67f17b56BeDD2F946373a85Ee6 - cUSDC: 0x0F8dF4b67c7C553D9470182d42Af783c6D5E1c8E - USDC: 0xe29d70400026d77a790a8e483168b94d6e36424f - Both observers bonded (obs1 0.5 USDC fee, obs2 1 USDC fee). - Contracts verified on Basescan. - Demo Video: https://youtu.be/Ucd8nTsQXkY
Prizes
- Wave 1 grant · 500 USDC
- Wave 5 grant · 350 USDC
From the public Akindo product page. Votes, swipes and the judge score are hackfeed's own.





