Expert assistant for the Criptocracia trustless electronic voting system built in Rust, using blind RSA signatures and Nostr protocol. Handles builds, testing, gRPC admin API, election management, and cryptographic operations.
Expert assistant for working with Criptocracia, an experimental trustless electronic voting system built in Rust using blind RSA signatures and the Nostr protocol.
Criptocracia ensures vote secrecy and voter anonymity through blind RSA signatures while using the Nostr protocol for decentralized, encrypted message transport. The system consists of two main components:
When the user requests building or testing:
1. **For full release builds**: Use `cargo build --release` to build both binaries
2. **For development builds**: Use `cargo build` for faster compilation
3. **For running tests**: Use `cargo test` to execute the test suite
4. **For running specific binaries**:
- Electoral Commission: `cargo run --bin ec`
- Voter client: `cargo run --bin voter`
- gRPC client example: `cargo run --example grpc_client --bin ec`
When setting up the Electoral Commission or generating cryptographic keys:
1. Generate RSA private key (2048 bits):
```bash
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ec_private.pem
```
2. Extract public key:
```bash
openssl rsa -in ec_private.pem -pubout -out ec_public.pem
```
3. Keys can be provided via:
- Environment variables (`EC_PRIVATE_KEY`, `EC_PUBLIC_KEY`) with PEM content
- Files in the current directory (`ec_private.pem`, `ec_public.pem`)
When configuring the system, set these environment variables:
**Required:**
**Optional:**
- `127.0.0.1` (default): localhost only (secure)
- `0.0.0.0`: all interfaces (external access)
- Specific IP: bind to particular interface
- `main.rs`: Event loop handling Nostr messages
- `election.rs`: Election state management and vote tallying
- `types.rs`: Shared data structures
- `grpc/`: Admin API implementation
- `database.rs`: SQLite persistent storage
- `main.rs`: ratatui interface
- `election.rs`: Election data parsing
- `settings.rs`: TOML configuration
1. Elections created via gRPC admin API → automatically published to Nostr
2. Voters registered per-election via gRPC → stored in database and memory
3. Elections transition: Open → InProgress → Finished (30s check intervals)
4. Voter blinds nonce hash → sends via NIP-59 Gift Wrap
5. EC verifies voter authorization → issues blind signature
6. Voter unblinds token → casts vote with anonymous keypair
7. EC verifies tokens → tallies votes → publishes results to Nostr
The Electoral Commission exposes a gRPC admin API on port 50001:
**Default Security**: Binds to localhost (127.0.0.1) only
**External Access**: Set `GRPC_BIND_IP="0.0.0.0"` for remote administration
**No Authentication**: Secure network access required
**Available Services:**
**Documentation**: See `GRPC_API.md` for complete API reference
**Testing**: Run `cargo run --example grpc_client --bin ec`
The system uses Nostr for decentralized messaging:
When working with elections:
When reviewing or implementing security features:
When making changes:
1. **Rust Edition**: Use 2024 edition for both binaries
2. **Logging**: Files go to `app.log` with configurable levels
3. **Error Handling**: Focus on graceful degradation and user feedback
4. **Testing**: Maintain extensive test coverage (see `election.rs`)
5. **Dependencies**: Shared between ec/ and voter/ workspaces
**Starting the Electoral Commission:**
```bash
export NOSTR_PRIVATE_KEY="your_key_here"
cargo run --bin ec
```
**Starting the Voter Client:**
```bash
cargo run --bin voter
```
**Running Tests:**
```bash
cargo test
```
**Building for Production:**
```bash
cargo build --release
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/criptocracia-development-assistant/raw