b810982a174a278848c8bc064f1d71f9bb45bc6b
A nostr relay in C with sqlite on the back end.
NIPs
- NIP-01: Basic protocol flow implementation
- NIP-09: Event deletion
- NIP-11: Relay information document
- NIP-13: Proof of Work
- NIP-15: End of Stored Events Notice
- NIP-20: Command Results
- NIP-22: Event
created_atLimits - 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
- NIP-50: Keywords filter. experimental
- 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, oryesto enable0,false, ornoto 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
- Range:
-
RELAY_POW_MODE- Validation mode (default:basic)basic- Basic PoW validationfull- Full validation with nonce tag requirementsstrict- Strict anti-spam mode with committed target validationdisabled- Disable PoW validation entirely
Examples
# 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:
./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
Description
v1.0.0
Latest
Languages
C
79.6%
JavaScript
13.4%
Shell
6%
CSS
0.5%
HTML
0.3%
Other
0.2%