Skip to content

fix(backend): validate Stellar account and contract identifiers #20 - #235

Merged
enliven17 merged 1 commit into
harpocrates-stellar:mainfrom
abrahambaba1:fix/20-validate-stellar-identifiers
Jul 29, 2026
Merged

fix(backend): validate Stellar account and contract identifiers #20#235
enliven17 merged 1 commit into
harpocrates-stellar:mainfrom
abrahambaba1:fix/20-validate-stellar-identifiers

Conversation

@abrahambaba1

Copy link
Copy Markdown
Contributor

Summary

Adds Stellar StrKey validation to the proof registration endpoint to prevent malformed source and contract identifiers from being stored.

Changes

  • New: backend/strkey.py — Implements base32 decoding/encoding and CRC16-XMODEM checksum verification for Stellar G-addresses and C-contract IDs
  • Modified: backend/app.py — Register endpoint now validates sourceAddress and contractId with field-specific error messages; allows null for both fields
  • New: backend/test_strkey.py — 36 unit tests covering valid checksums, wrong types, tampered payloads, invalid characters, wrong length, nullable handling, and case-insensitive normalization (all pass)
  • Modified: backend/test_app.py — Updated test fixtures with properly valid Stellar addresses
  • Modified: backend/load_test.py — Synthetic load test payloads omit sourceAddress/contractId
  • Modified: backend/db.py — Added pre-existing missing functions (set_legal_hold, purge_expired_events, enqueue_job, get_job, cancel_job)

Acceptance Criteria

  • Validate G-addresses and C-contract IDs with Stellar StrKey semantics
  • Allow explicitly documented nullable fields
  • Return field-specific errors
  • Test valid checksums, wrong types, and malformed values

Closes #20

…crates-stellar#20

Add Stellar StrKey validation to the proof registration endpoint.

- Implement StrKey base32 decoding and CRC16-XMODEM checksum
  verification in backend/strkey.py
- Validate G-addresses (sourceAddress) and C-contract IDs (contractId)
  with proper Stellar StrKey semantics
- Allow explicitly nullable fields (None accepted for both)
- Return field-specific error messages on invalid input
- Add 36 unit tests covering valid checksums, wrong types, malformed
  values, nullable handling, and case-insensitive input
- Update existing test fixtures with valid Stellar addresses
- Fix pre-existing missing function imports in db.py

Closes harpocrates-stellar#20
@abrahambaba1
abrahambaba1 requested a review from enliven17 as a code owner July 29, 2026 11:29
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@abrahambaba1 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

@enliven17
enliven17 merged commit 6ad669d into harpocrates-stellar:main Jul 29, 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

Development

Successfully merging this pull request may close these issues.

fix(backend): validate Stellar account and contract identifiers

2 participants