Skip to content

About

Standalone commercial CoreGuard Verify product (Pi-first); consumes CoreGuard engine via a clean integration boundary. No production/conformance claim.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreGuard-Verify — Pi Network

A standalone commercial product in coreguard-global, consuming CoreGuard as an independent engine. This repository now contains a working testnet prototype: a Pi app, a merchant hub, an adversarial attack lab, an independent receipt verifier, a three-line developer SDK, and retry/resume handling for the payments Pi hands back when a flow is interrupted.

npm start          # http://localhost:3000  (zero dependencies, Node 20+)

If PI_API_KEY is present the app talks to the real Pi Platform API. Without it the app runs a deterministic sandbox ledger, labels itself SANDBOX in the UI, and moves no funds.

What the product does

  1. A Pioneer signs in with Pi; the server verifies the access token against GET /v2/me.
  2. The server issues an authorization intent: amount from the published price book, payee = app wallet, single-use nonce, ten-minute expiry.
  3. Approval (POST /v2/payments/:id/approve) only happens after an ALLOW decision — so a refused payment never unlocks the wallet.
  4. Completion re-reads the payment from the platform and compares the executed amount, payee and txid to the intent. Mismatch ⇒ no completion.
  5. Everything is sealed into an evidence receipt: ordered steps, SHA-256 chain, an Ed25519 seal anyone can check against the published key, plus an internal HMAC, and a verdict of ALLOW, BLOCK or UNKNOWN. UNKNOWN never settles.

Retry and resume

Pi can deliver the same approval twice, and a phone network can duplicate a request. Money mutations must therefore be idempotent:

  • authorize and complete are keyed on paymentId. Repeating one returns the same decision and the same sealed receipt instead of approving twice or judging twice.
  • complete refuses a payment this server never authorized, and refuses an intent that belongs to another Pioneer.
  • POST /api/payments/resume finishes a payment Pi reports as interrupted (onIncompletePaymentFound). It never invents an ALLOW: if the payment cannot be tied to a server-side intent, the answer is UNKNOWN.
  • The Pi transport retries GET calls with backoff and a timeout, and never blind-retries approve/complete — after an ambiguous POST it re-reads the payment state instead.

Surfaces

Route Audience What it proves
/ judge / visitor positioning, live counters, honest boundaries
/app.html Pioneer pay once, leave with a verifiable receipt
/merchant.html merchant price book, payment ledger, refused attempts, embeddable badge
/attack.html judge / security seven attacks, each with the receipt that refused it
/verify.html anyone stateless verification: recompute the chain and seal
/developers.html Pi developer three-line integration, API reference, capability matrix

Configuration

Variable Meaning
PI_API_KEY Pi Server API Key — server side only, never in the browser
PI_NETWORK testnet (default) or mainnet; an app is registered for one network only
PI_APP_WALLET app wallet that receives U2A payments
PORT / HOST bind address, defaults 3000 / 0.0.0.0
PI_PLATFORM_BASE override for the Platform API base, defaults https://api.minepi.com/v2
PI_TIMEOUT_MS / PI_ATTEMPTS Platform call timeout (8s) and attempt count for retryable GETs
PI_VALIDATION_KEY domain-ownership key, served at /validation-key.txt (PiNet / Pi Sign-in)
PI_APP_DOMAIN verified app domain, reported by /api/pinet
PI_PINET_SUBDOMAIN PiNet subdomain once the Developer Portal issues it

No secret is committed. .data/ (the local ledger and the Ed25519 issuer key) is git-ignored.

Verify it yourself

npm run verify                                   # 70 end-to-end checks, exits non-zero on failure
curl -s localhost:3000/api/receipts | head -c 200
curl -s localhost:3000/api/receipts/rcpt_xxx | node scripts/verify-receipt.mjs   # standalone

scripts/verify-receipt.mjs imports no CoreGuard code: it rebuilds the chain and checks the Ed25519 seal against GET /api/issuer-key, so a receipt can be checked without trusting this server.

Boundaries — read these before quoting anything

  • VERIFIED != SAFE, PASS != SAFE, UNKNOWN != VERIFIED. Missing evidence is never success.
  • No mainnet claim. Pi requires Core Team approval for the incoming multisig wallet; until that exists the product is testnet only.
  • No Pi protocol-level interception or protection.
  • No revenue, customers, partners, audits or funding are claimed anywhere in this repository.
  • The badge fails closed: no settled receipts, no badge.

Documents

  • docs/PI-CAPABILITY-MATRIX.md — every capability with its literal state.
  • docs/CODE-REVIEW.md — what was wrong, what was fixed, what is deliberately accepted.
  • docs/DEMO-SCRIPT.md — the three-minute judge demo, beat by beat, with recovery lines.
  • docs/PI-NET-INTEGRATION.md — PiNet rules, what is implemented, what is still blocked.
  • docs/THIRD-PARTY-LICENSES.md — Pi SDK / Platform API terms, PiOS, and dependency licensing.
  • docs/PI-INTEGRATION.md — developer quickstart and error/state contract.
  • docs/PI-NEXT-*.md, docs/PI-INTEGRATION-ARCHITECTURE.md — the original plan, P0→P6, still the source of truth for what comes after the prototype.

Layout

server/    index.mjs (HTTP + routes) · policy.mjs (ALLOW/BLOCK/UNKNOWN) ·
           receipts.mjs (chain + Ed25519/HMAC seal) · pi.mjs (live/sandbox transport) · store.mjs
public/    pages, design system (css/coreguard.css), embed-badge.js, sdk/pi-verify.mjs
scripts/   verify-all.mjs (70 end-to-end checks) · verify-receipt.mjs (standalone verifier)

About

Standalone commercial CoreGuard Verify product (Pi-first); consumes CoreGuard engine via a clean integration boundary. No production/conformance claim.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages