Skip to content

feat: implement attestation, XDR encoding, consensus, and wallet throttling - #539

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
observerr411:main
Aug 30, 2026
Merged

feat: implement attestation, XDR encoding, consensus, and wallet throttling#539
Just-Bamford merged 1 commit into
Sorokit:mainfrom
observerr411:main

Conversation

@observerr411

Copy link
Copy Markdown
Contributor

Summary

Resolves four issues in a single PR.


closes #508 — Account attestation & credential management

  • Typed AccountAttestation and CredentialMetadata model in the account module
  • issueAttestation(subject, credential) with issuer validation and deterministic HMAC-SHA256 payload signing
  • verifyAttestation(attestation) for signature, subject, and expiration verification
  • revokeAttestation with revocation registry; revoked credentials fail verification even with valid signatures
  • Duplicate prevention via per-account issuance registry (same issuer + credential ID rejected)
  • getAccountAttestations(account, filters) — query by issuer, type, credential ID, or validity (checks registry for post-storage revocations)
  • Structured SorokitError responses for expired, malformed, revoked, or untrusted attestations
  • Private credential attributes never exposed through logs or serialized errors
  • Exported from src/account/index.ts and src/index.ts
  • 24 tests covering issuance, verification, expiration, revocation, duplicate detection, malformed signatures, invalid issuers, and query filtering

closes #505 — Transaction XDR encoding for bandwidth efficiency

  • Optional DEFLATE compression for large XDR payloads with byte-for-byte round-trip fidelity
  • Delta-based encoding for similar transaction structures using prefix-diff representation
  • EncodingMetadata identifies the strategy required for decoding (none / deflate / delta)
  • Small payloads bypass compression automatically when overhead exceeds savings threshold
  • Compression failures fall back safely to standard uncompressed XDR
  • Configurable: minCompressionSize, maxCompressionOverhead, compressionLevel, enableDeltaEncoding
  • Exported from src/transaction/index.ts and src/index.ts
  • 23 tests covering round-trips, corrupted payloads, small payloads, delta encoding, cache management, and config options

closes #507 — Threshold-based multi-party transaction consensus

  • createConsensusTransaction(threshold, participants) validates threshold ≤ participant count and no duplicate IDs
  • Independent tracking of approvals, rejections, and pending participants per consensus workflow
  • States: proposal → review → approved / rejected → finalized
  • Duplicate approvals/rejections from the same participant are rejected with structured errors
  • finalizeConsensusTransaction is blocked until threshold is met and no rejections exist
  • Consensus state is kept separate from the underlying transaction object — no silent submission
  • Exported from src/transaction/index.ts and src/index.ts
  • 26 tests covering threshold success, rejection, duplicates, invalid config, and full workflow

closes #506 — Wallet connection throttling & abuse detection

  • Per-origin rate limiting with configurable attempt window and block duration
  • Authentication failure tracking contributes to abuse detection independently of general failures
  • Excessive requests trigger temporary backoff; blocked requests return structured errors with retryAfterMs
  • Allowlist and blocklist rules with optional expiration (no restart required)
  • detectAbuse(origin) scores confidence across patterns: rapid attempts, repeated failures, auth failures, high failure rate
  • Existing wallet integrations unaffected when enabled: false
  • Exported from src/wallet/index.ts and src/index.ts
  • 39 tests covering normal retries, bursts, auth failures, allowlists, blocklists, expiry, and structured errors

Test results

✓ src/wallet/throttling.test.ts       39 tests
✓ src/account/attestation.test.ts     24 tests
✓ src/transaction/consensus.test.ts   26 tests
✓ src/transaction/xdrEncoding.test.ts 23 tests

Test Files  4 passed (4)
Tests       112 passed (112)

- closes Sorokit#508: Add account attestation and credential management with
  issueAttestation, verifyAttestation, revokeAttestation, and
  getAccountAttestations. Deterministic HMAC-SHA256 signing, expiry
  and revocation checks, duplicate prevention, and private attribute
  safety. Exported from account/index.ts and src/index.ts.

- closes Sorokit#505: Add transaction XDR encoding optimization with
  DEFLATE compression, delta-based encoding, and auto strategy
  selection. Transparent fallback for small payloads and compression
  failures. Exported from transaction/index.ts and src/index.ts.

- closes Sorokit#507: Add threshold-based multi-party transaction consensus
  with createConsensusTransaction, approve/reject, summary tracking,
  and finalization guard. Prevents duplicate votes and impossible
  thresholds. Exported from transaction/index.ts and src/index.ts.

- closes Sorokit#506: Add wallet connection throttling and abuse detection
  with per-origin rate limiting, auth failure tracking, allowlist/
  blocklist support, structured error responses, and expiring blocks.
  Exported from wallet/index.ts and src/index.ts.

All 112 tests pass (39 throttling, 24 attestation, 26 consensus,
23 XDR encoding).
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@observerr411 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Just-Bamford
Just-Bamford merged commit 9ed7411 into Sorokit:main Aug 30, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants