Repository navigation
Upgrade/security and core - #1
Merged
Merged
Conversation
…-GCM) Replaces the placeholder AES/base64 scheme with real t-of-n threshold encryption: - orderCipher.ts: clients encrypt to the validator group key Y. Ephemeral r, R = rG, K = rY, HKDF-SHA256 -> AES-256-GCM, with R and the user's address as AAD so a ciphertext can't be replayed under another account. Environment-neutral (WebCrypto + @noble/curves) and shipped byte-identically to the frontend; a test enforces the copies match. - threshold.ts: Shamir key sharing, per-validator partial decryption D_i = y_i*R with a Chaum-Pedersen DLEQ proof, proof verification, and Lagrange combination of any t verified shares into K = yR. Keygen is a trusted dealer for now (simulated validator set); a DKG is the documented next step. Backend tests move to Vitest, since stellar-sdk 17's ESM dependencies can't load under Jest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…only The order pipeline now actually depends on the encryption: - Clients submit only encrypted_data + threshold_pubkey + nonce. Tokens and amounts are no longer sent in plaintext alongside the ciphertext; the Order columns for them stay NULL until the batch is decrypted. - validatorNetwork: a simulated t-of-n validator set (default 3-of-5), each node holding one key share, behind an async per-validator interface so remote validators can replace it. BYZANTINE_VALIDATORS injects faulty nodes for demos. - validatorService.coordinateDecryption: collects shares for a sealed batch, verifies every DLEQ proof against the registered verification key, combines t good shares, decrypts, and validates the payload (user binding, nonce match, base-unit integer amounts). A bad order fails alone without blocking its batch. - The batching loop now seals, decrypts, and settles in one pass. A conditional status claim prevents double settlement. The unauthenticated 'settle with these decrypted orders' endpoint is gone; POST /settlement/:id/settle now only retries the honest path. - Intake rejects malformed ciphertext, stale threshold keys, and reused nonces. - Frontend converts amounts to 7-decimal base units exactly; settlement previously called BigInt() on strings like '10.5' and would throw. - Express app split from server start (app.ts) for testing. 12 new end-to-end tests cover reveal-after-settle, byzantine tolerance (2 of 5 bad nodes), failure past n-t, cross-user replay, malformed orders, and double settlement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…0 style) The backend trusted an x-user-address header, so anyone could act as any address. Now: - POST /api/auth/challenge returns a transaction sourced from the user's account with sequence 0 (it can never be submitted on-chain), carrying a manageData value expiry || random || HMAC. The HMAC makes challenges stateless and unforgeable by clients. - POST /api/auth/verify checks the HMAC, the 5-minute expiry, and the ed25519 signature over the tx hash against the source account, then issues a 1-hour HMAC session token. - validateAuth takes the address only from a verified token. GET /orders/user/:address now requires auth and only returns your own orders, since sealed orders still leak timing. - Frontend signs the challenge in Freighter, caches the session per tab, and clears it on disconnect. This also fixes signTransaction passing 'TESTNET' as the network passphrase. 8 new tests: spoofed signer, unsigned and self-forged challenges, tampered tokens, the legacy header rejected, and order-history privacy. All 31 backend tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Frontend: Vitest + Testing Library. SwapForm test proves the POST body
holds only {encrypted_data, threshold_pubkey, nonce}, carries the
session header, and decrypts to the exact base-unit order. Also covers
exact decimal-to-base-unit conversion, validation, and display.
- CI (GitHub Actions): backend typecheck/test/build, frontend test/build,
contracts cargo test, on every push to main and every PR.
- scripts/check-source-integrity.sh, run as the first CI job: fails on
minified-length lines, code hidden behind long whitespace runs, and
eval/Function-constructor/large-atob usage. All three detectors fire on
the payload removed in 61714e4, so a repeat injection can't merge
unnoticed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d issues - docs/THRESHOLD_ENCRYPTION.md: the scheme, each security property mapped to the test that checks it, and what is still simulated (trusted-dealer keygen, in-process validators). - SECURITY.md: private reporting, scope, and supply-chain hygiene. - README, backend README, CONTRIBUTING, and the in-app docs page now describe what is actually implemented, plus the API table and test commands. - CONTRIBUTOR_ISSUES.md: the finished issues are removed; new scoped issues cover DKG, remote validators, on-chain ciphertext commitments, migrations, rate limiting, and more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SYMBAxx
added a commit
that referenced
this pull request
Nov 7, 2026
Explain the DKG rounds, map each DKG property to its test, and state its limitations (Joint-Feldman key bias, broadcast assumption). The 'simulated' caveat is now precise: there is no dealer, but validators sharing one process means one operator could still collect t shares until the validators run remotely. Contributor issue #1 becomes the GJKR unbiased-DKG upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
x-user-addressheader. Order history is private to its owner.Fixes
BigInt()on decimal strings like "10.5"; amounts are now converted to exact base units in the browser.signTransactionwas given'TESTNET'instead of the network passphrase.Breaking changes
POST /api/ordersnow takes only{encrypted_data, threshold_pubkey, nonce}and requires a Bearer session.AUTH_TOKEN_SECRET,VALIDATOR_COUNT,VALIDATOR_THRESHOLD(seebackend/.env.example).Still simulated
The validators run in-process, and keys come from a trusted dealer. See
docs/THRESHOLD_ENCRYPTION.md. Distributed key generation and remote validators are tracked as contributor issues.Test plan