Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 2 * * *'
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -20,3 +22,19 @@ jobs:
- run: pnpm run format:check
- run: pnpm build
- run: pnpm test

slow-tests:
name: Property fuzz (nightly)
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm test:fuzz
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,31 @@ const metaAddress = metaAddressFromNameData(cellData);
// => "st:ckb:..."
```

## Property tests

The Stellar scalar module is covered by [fast-check](https://fast-check.dev/) property tests in `test/chains/stellar/properties.test.ts`. These go beyond fixed unit tests by generating thousands of random inputs and asserting mathematical invariants:

| Property | What it checks |
| --------------------------- | ------------------------------------------------------------------------------------- |
| Addition associativity | `(a+b)+c == a+(b+c) mod L` for all scalars |
| Addition commutativity | `a+b == b+a mod L` |
| Additive identity | `a+0 == a mod L` |
| Reduction stability | `bytesToScalar(scalarToBytes(a)) == a` round-trips losslessly |
| `seedToScalar` determinism | same seed → same scalar; distinct seeds → distinct scalars |
| Stealth equation | `(m + s_h)*G == m*G + s_h*G` — the homomorphism that makes stealth spending work |
| View-tag uniformity | chi-square test over 10k inputs confirms `computeViewTag` output is uniform `[0,255]` |
| `signWithScalar` round-trip | every `(scalar, message)` pair produces a verifiable ed25519 signature |

```bash
# Standard run — 1 000 cases per property
pnpm test

# Thorough fuzz run — 100 000 cases per property
pnpm test:fuzz
```

The nightly CI job (`slow-tests`) runs `pnpm test:fuzz` automatically at 02:00 UTC.

## Documentation

Full protocol documentation, architecture details, and integration guides are available at [wraith-protocol/docs](https://github.com/wraith-protocol/docs).
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@
"clean": "rm -rf dist",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky"
"prepare": "husky",
"test:fuzz": "FC_RUNS=100000 vitest run test/chains/stellar/properties.test.ts"
},
"dependencies": {
"@noble/curves": "^1.8.0",
"@noble/hashes": "^1.7.0",
"viem": "^2.23.0"
},
"peerDependencies": {
"@stellar/stellar-sdk": "^13.1.0",
"@solana/web3.js": "^1.95.0"
"@solana/web3.js": "^1.95.0",
"@stellar/stellar-sdk": "^13.1.0"
},
"peerDependenciesMeta": {
"@stellar/stellar-sdk": {
Expand All @@ -63,6 +64,7 @@
"@commitlint/config-conventional": "^19.6.0",
"@solana/web3.js": "^1.98.4",
"@stellar/stellar-sdk": "^13.1.0",
"fast-check": "^4.8.0",
"husky": "^9.1.0",
"prettier": "^3.4.0",
"tsup": "^8.4.0",
Expand Down
35 changes: 22 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading