|
| 1 | +@.claude/ardenthq/core.md |
| 2 | +# python-crypto - ARK Blockchain Cryptography |
| 3 | + |
| 4 | +## Project Overview |
| 5 | + |
| 6 | +Python cryptography library for the ARK blockchain. Handles transaction building, serialization/deserialization, identity management (addresses, public/private keys, WIF), message signing/verification, and Schnorr signatures. |
| 7 | + |
| 8 | +## Tech Stack |
| 9 | + |
| 10 | +- **Language**: Python |
| 11 | +- **Crypto**: coincurve (libsecp256k1 bindings), base58, binary-helpers |
| 12 | +- **Testing**: pytest + pytest-cov |
| 13 | +- **Linting**: flake8 (+ flake8-import-order, flake8-print, flake8-quotes) |
| 14 | + |
| 15 | +## Directory Structure |
| 16 | + |
| 17 | +- `crypto/` - Main package |
| 18 | + - `configuration/` - Fee and network configuration |
| 19 | + - `fee.py` - Fee management (get/set fees per transaction type) |
| 20 | + - `network.py` - Network configuration (get/set active network) |
| 21 | + - `constants.py` - Transaction types, type groups, HTLC expiration types |
| 22 | + - `exceptions.py` - Custom exceptions |
| 23 | + - `identity/` - Identity utilities |
| 24 | + - `address.py` - Address derivation from passphrase/public key/private key |
| 25 | + - `private_key.py` - Private key from passphrase/hex |
| 26 | + - `public_key.py` - Public key from passphrase/hex |
| 27 | + - `wif.py` - WIF (Wallet Import Format) encoding |
| 28 | + - `networks/` - Network presets (devnet, mainnet, testnet) |
| 29 | + - `schnorr/` - Schnorr signature implementation |
| 30 | + - `transactions/` - Transaction handling |
| 31 | + - `builder/` - Transaction builders (one per type): transfer, vote, delegate_registration, delegate_resignation, multi_payment, multi_signature_registration, second_signature_registration, ipfs, htlc_lock, htlc_claim, htlc_refund |
| 32 | + - `serializer.py` / `serializers/` - Transaction serialization (one per type) |
| 33 | + - `deserializer.py` / `deserializers/` - Transaction deserialization (one per type) |
| 34 | + - `transaction.py` - Transaction data class |
| 35 | + - `utils/` - Utilities |
| 36 | + - `message.py` - Message signing/verification |
| 37 | + - `slot.py` - Time slot calculations |
| 38 | +- `tests/` - Tests mirroring crypto/ structure |
| 39 | +- `Makefile` - `make test` and `make lint` |
| 40 | + |
| 41 | +## Key Patterns |
| 42 | + |
| 43 | +- **Transaction builders** extend `BaseTransactionBuilder` in `builder/base.py`, set `transaction_type` and build transaction objects |
| 44 | +- **Serializers/Deserializers** extend base classes, one per transaction type |
| 45 | +- **Identity** functions derive addresses/keys from passphrases using Schnorr |
| 46 | +- **Network config** is global — set via `set_network()`, read via `get_network()` |
| 47 | +- **Fee config** is global — set via `set_fee()`, read via `get_fee()` |
| 48 | + |
| 49 | +## Branches |
| 50 | + |
| 51 | +- Base branch: `feat/mainsail` (always use this as base for PRs) |
| 52 | +- **Always create a new branch** from `feat/mainsail` before starting any task |
| 53 | +- Branch names follow conventional commit prefixes: `feat/`, `fix/`, `chore/`, `refactor/`, `style/`, `docs/`, `test/` |
| 54 | +- Use short, descriptive kebab-case names after the prefix |
| 55 | + |
| 56 | +## Testing |
| 57 | + |
| 58 | +- Run tests: `make test` or `pytest -v -s` |
| 59 | +- Run lint: `make lint` or `flake8 .` |
| 60 | +- **100% code coverage is required** — CI enforces `--cov-fail-under=100` |
| 61 | +- Flake8 config: `max-line-length = 100` (in `setup.cfg`) |
| 62 | + |
| 63 | +## After completing a task, ALWAYS run these checks (in order) |
| 64 | + |
| 65 | +1. `make lint` - flake8 |
| 66 | +2. `make test` - pytest (must pass with 100% coverage) |
| 67 | + |
| 68 | +## Commits |
| 69 | + |
| 70 | +- **Commit as you progress** — make commits incrementally as you complete logical chunks of work, don't wait until the end |
| 71 | +- Use conventional commits (feat:, fix:, chore:, style:, refactor:, etc.) |
| 72 | +- NEVER add Co-Authored-By or any collaborator line |
| 73 | +- NEVER add description/body to commits, ONLY the subject line |
| 74 | +- Keep commit messages SHORT — ideally under 50 chars, never long |
| 75 | +- Write commit messages naturally like a human would, not overly polished or perfect. Quick and casual is fine, minor typos are ok |
| 76 | +- Examples of good commit messages: |
| 77 | + - `feat: add wallet search endpoint` |
| 78 | + - `fix: wrong query param encoding` |
| 79 | + - `chore: update deps` |
| 80 | + - `refactor: extract shared pagination logic` |
0 commit comments