90 lines
2.9 KiB
Markdown
90 lines
2.9 KiB
Markdown
A nostr relay in C with sqlite on the back end.
|
|
|
|
<!--
|
|
NOTE FOR ASSISTANTS: When updating the NIPs checklist below, ONLY change [ ] to [x] to mark as complete.
|
|
Do NOT modify the formatting, add emojis, or change the text. Keep the simple format consistent.
|
|
-->
|
|
|
|
|
|
### [NIPs](https://github.com/nostr-protocol/nips)
|
|
|
|
- [x] NIP-01: Basic protocol flow implementation
|
|
- [x] NIP-09: Event deletion
|
|
- [x] NIP-11: Relay information document
|
|
- [x] NIP-13: Proof of Work
|
|
- [x] NIP-15: End of Stored Events Notice
|
|
- [x] NIP-20: Command Results
|
|
- [ ] NIP-22: Event `created_at` Limits
|
|
- [ ] NIP-25: Reactions
|
|
- [ ] NIP-26: Delegated Event Signing
|
|
- [ ] NIP-28: Public Chat
|
|
- [ ] NIP-33: Parameterized Replaceable Events
|
|
- [ ] NIP-40: Expiration Timestamp
|
|
- [ ] NIP-42: Authentication of clients to relays
|
|
- [ ] NIP-45: Counting results. [experimental](#count)
|
|
- [ ] NIP-50: Keywords filter. [experimental](#search)
|
|
- [ ] NIP-70: Protected Events
|
|
|
|
## NIP-13: Proof of Work Configuration
|
|
|
|
The relay supports NIP-13 Proof of Work validation with configurable settings. PoW validation helps prevent spam and ensures computational commitment from event publishers.
|
|
|
|
### Environment Variables
|
|
|
|
Configure PoW validation using these environment variables:
|
|
|
|
- `RELAY_POW_ENABLED` - Enable/disable PoW validation (default: `1`)
|
|
- `1`, `true`, or `yes` to enable
|
|
- `0`, `false`, or `no` to disable
|
|
|
|
- `RELAY_MIN_POW_DIFFICULTY` - Minimum required difficulty (default: `0`)
|
|
- Range: `0-64` (reasonable bounds)
|
|
- `0` = no minimum requirement (events without PoW are accepted)
|
|
- Higher values require more computational work
|
|
|
|
- `RELAY_POW_MODE` - Validation mode (default: `basic`)
|
|
- `basic` - Basic PoW validation
|
|
- `full` - Full validation with nonce tag requirements
|
|
- `strict` - Strict anti-spam mode with committed target validation
|
|
- `disabled` - Disable PoW validation entirely
|
|
|
|
### Examples
|
|
|
|
```bash
|
|
# Basic setup - accept events with or without PoW
|
|
export RELAY_POW_ENABLED=1
|
|
export RELAY_MIN_POW_DIFFICULTY=0
|
|
export RELAY_POW_MODE=basic
|
|
|
|
# Anti-spam setup - require minimum difficulty 16
|
|
export RELAY_POW_ENABLED=1
|
|
export RELAY_MIN_POW_DIFFICULTY=16
|
|
export RELAY_POW_MODE=strict
|
|
|
|
# Disable PoW validation completely
|
|
export RELAY_POW_ENABLED=0
|
|
```
|
|
|
|
### Behavior
|
|
|
|
- **min_difficulty=0**: Events without PoW are accepted; events with PoW are validated
|
|
- **min_difficulty>0**: All events must have valid PoW meeting minimum difficulty
|
|
- **strict mode**: Additional validation prevents difficulty commitment gaming
|
|
- **NIP-11 integration**: PoW configuration is advertised via relay information document
|
|
|
|
### Testing
|
|
|
|
Run the comprehensive PoW test suite:
|
|
|
|
```bash
|
|
./tests/13_nip_test.sh
|
|
```
|
|
|
|
The test suite validates:
|
|
- NIP-11 PoW support advertisement
|
|
- Event acceptance without PoW (when min_difficulty=0)
|
|
- Event validation with valid PoW
|
|
- Configuration via environment variables
|
|
- NIP-13 reference event validation
|
|
|